From c7a6b173102b5df624ce18780e057b3d61953ce6 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 9 Jun 2008 19:51:56 +0000 Subject: [PATCH] Some more fixes to selects --- CHANGELOG.txt | 1 + includes/reserved.inc | 2 +- includes/ui/ui_lists.inc | 26 ++++++++++++++------------ js/inserts.js | 13 +------------ 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 24e3f6db..26653fd1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -26,6 +26,7 @@ $ /gl/gl_journal.php /gl/gl_deposit.php /gl/gl_payment.php /includes/ajax.inc + /includes/reserved.inc /includes/ui/ui_lists.inc /includes/ui/ui_view.inc /js/inserts.js diff --git a/includes/reserved.inc b/includes/reserved.inc index 5f376ade..14b2d8cc 100644 --- a/includes/reserved.inc +++ b/includes/reserved.inc @@ -4,7 +4,7 @@ $any_item = 'AN'; $any_number = -1; -$all_option = "___ALL___"; +$all_option = ''; $all_option_numeric = -1; class reserved_words diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 785ab746..4b2294e3 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -121,8 +121,8 @@ $opts = array( // default options $sql .= $limit; // ------ make selector ---------- - $selector = ''; - $first_id = $first_opt = ''; + $selector = $first_opt = ''; + $first_id = false; $found = false; //if($name=='code_id') display_error($sql); if($result = db_query($sql)) { @@ -153,12 +153,13 @@ $opts = array( // default options } db_free_result($result); } - // add first option - selected also if no match for selected_id was found - // and no special option defined - $sel = $spec_option===false || $found === $first_id ? 'selected' : ''; - $selector = "\n" + if ($first_id !== false) { + // add first option - selected also if no match for selected_id was found + // and no special option defined + $sel = $spec_option===false || $found === $first_id ? 'selected' : ''; + $selector = "\n" . $selector; - + } // Prepend special option. if ($spec_option !== false) { // if special option used - add it $first_id = $spec_id; @@ -170,21 +171,22 @@ $opts = array( // default options $sel = $found===false ? 'selected' : ''; $selector = "\n" . $selector; + $first_id = $spec_id; } if ($found === false) { - $_POST[$name] = $first_id; + $_POST[$name] = $first_id; } if ($by_id) { - $txt = $_POST[$name]; - if ($search_box) - $Ajax->addUpdate($name, $search_box, $txt); + $txt = $_POST[$name]; + if ($search_box) + $Ajax->addUpdate($name, $search_box, $txt); } $selector = "\n"; + . $opts['sel_hint']."' $rel>".$selector."\n"; $Ajax->addUpdate($name, "_{$name}_sel", $selector); diff --git a/js/inserts.js b/js/inserts.js index 43b5f43b..2b244ec5 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -85,9 +85,7 @@ function _update_box(s) { var box = document.getElementsByName(rel)[0]; if(box && s.selectedIndex>=0) { var opt = s.options[s.selectedIndex]; - if (opt.value != 0) { if(box) box.value = byid ? opt.value : opt.text; - } } } @@ -143,16 +141,7 @@ var inserts = { // this hides search button for js enabled browsers e.style.display = 'none'; }, -/* 'select.combo,select.combo2': - function(e) { - var box = document.getElementsByName(e.getAttribute('rel'))[0]; - if(box) { - box.style.width = 200+'px'; - e.style.width = 200+'px'; - debug(e.name+':'+e.style.width) - } - }, -*/ 'input.ajaxsubmit,input.editbutton,input.navibutton': + 'input.ajaxsubmit,input.editbutton,input.navibutton': function(e) { e.onclick = function() { JsHttpRequest.request(this.name); -- 2.30.2