diff --git a/header.inc.php3 b/header.inc.php3 index 1c25649e8..f9b0002f5 100755 --- a/header.inc.php3 +++ b/header.inc.php3 @@ -135,6 +135,13 @@ var errorMsg2 = '' +//--> + + + diff --git a/libraries/tbl_change.js b/libraries/tbl_change.js new file mode 100644 index 000000000..fe90ffea7 --- /dev/null +++ b/libraries/tbl_change.js @@ -0,0 +1,59 @@ +/* $Id$ */ + + +/** + * Modify from controls when the "NULL" checkbox is selected + * + * @param string the MySQL field type + * @param string the urlencoded field name + * @param string the md5 hashed field name + * + * @return boolean always true + */ +function nullify(theType, urlField, md5Field) +{ + var rowForm = document.forms['insertForm']; + + if (typeof(rowForm.elements['funcs[' + urlField + ']']) != 'undefined') { + rowForm.elements['funcs[' + urlField + ']'].selectedIndex = -1; + } + + // "SET" field or "ENUM" field with more than 20 characters + if (theType == 1 || theType == 3) { + rowForm.elements['field_' + md5Field + '[]'].selectedIndex = -1; + } + // Other "ENUM" field + else if (theType == 2) { + var elts = rowForm.elements['field_' + md5Field + '[]']; + var elts_cnt = elts.length; + for (var i = 0; i < elts_cnt; i++ ) { + elts[i].checked = false; + } // end for + } + // Other field types + else /*if (theType == 4)*/ { + rowForm.elements['fields[' + urlField + ']'].value = ''; + } // end if... else if... else + + return true; +} // end of the 'nullify()' function + + +/** + * Unchecks the "NULL" control when a function has been selected or a value + * entered + * + * @param string the urlencoded field name + * + * @return boolean always true + */ +function unNullify(urlField) +{ + var rowForm = document.forms['insertForm']; + + if (typeof(rowForm.elements['fields_null[' + urlField + ']']) != 'undefined') { + rowForm.elements['fields_null[' + urlField + ']'].checked = false + } // end if + + return true; +} // end of the 'unNullify()' function diff --git a/tbl_change.php3 b/tbl_change.php3 index 04f03b5c0..e7f3a9fcf 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -6,6 +6,7 @@ * Get the variables sent or posted to this script and displays the header */ require('./libraries/grab_globals.lib.php3'); +$js_to_run = 'tbl_change.js'; include('./header.inc.php3'); // Displays the query submitted and its result if (!empty($message)) { @@ -111,8 +112,12 @@ else /** * Displays the form */ - -// Had to put the URI because when hosted on an https server, +// loic1: autocomplete feature of IE kills the "onchange" event handler and it +// must be replaced by the "onpropertychange" one in this case +$chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5) + ? 'onpropertychange' + : 'onchange'; +// Had to put the URI because when hosted on an https server, // some browsers send wrongly this form to the http server. ?> @@ -257,7 +262,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { } else { ?>