Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by andy on Jan 16, 2008 02:02
open dhtmlx forum
Value not being returned?

Hi guys, the below code loads the combo fine and adds the values but the onchange event shows a blank alert box?

<div id="valtype" style="width:200px; height:30px;"></div>
<script>
window.dhx_globalImgPath="../images/";
var z=new dhtmlXCombo("valtype","valtype",200);
z.addOption('MV','Mortgage Valuation');
z.addOption('DB','Driveby');
z.addOption('RI','ReInspection');
z.addOption('CM','Commercial Valuation');
z.addOption('TV','Test Valuation');    
z.attachEvent("onChange",function(){ alert(z.getComboText()); });
</script>
Answer posted by Support on Jan 16, 2008 05:58
In existing version on moment of onchange event only value set for combo.
Problem already fixed in dev. code - it will be released as part of next build. If you need it ASAP - please use attached js file instead of original one.
Attachments (1)
Answer posted by Kevin on Apr 09, 2008 18:57
I have the same problem with the new code...dated 2008-3-20
Answer posted by Support on Apr 10, 2008 01:55
Problem can't be reconstructed with latest code - please check attached sample.
Attachments (1)
Answer posted by Kevin on Apr 10, 2008 20:01

The problem is, the combobox value is not set unless the value is changed.  Therefore, when I default the value on page load, then user clicks submit...the value is null.

My code...

<div id="combo_country" style="width:60px; height:30px;"></div><script>var z1=new dhtmlXCombo("combo_country","country",60);z1.setComboText("<?=$country?>");z1.enableFilteringMode(true,"ip_lookup/get_countries.php",true);</script>

When country equals US in drop down, but unless the user clicks in drop down, value is null on page submit.

Thanks.

Answer posted by Support on Apr 11, 2008 01:57
The combo has different commands to set selected text and selected value, you can use
    combo.setComboValue(value);   //value which will be send during submit
Answer posted by Kevin on Apr 14, 2008 18:31

setComboValue works on page load.  I am talking about another problem, not on load...but on submit.

This problem I am talking about is when the user is typing in the value, then hitting the submit button.  If you click in the box, or hit tab...the value the user typed will always be submitted with the form.

However, if the user just types in the combo box then clicks on submit...the NEW VALUE is hit or miss on submit.

Please help!

Answer posted by Support on Apr 15, 2008 02:41
The combo changes its value in next cases
    - direct selection by click
    - direct selection by enter key
    - typing value and onBlur event

When you clicking any button outside of combo, onBlur event occurs and value in combo changed
If it still not works in you case, you can force onBlur event by using next code

       <input type="submit" onclick="combo._confirmSelection()"/>
Answer posted by Kevin on May 10, 2008 21:00

Thanks,

I do have to call your onblur action to make it work, I wonder if it is because I have an image submit button.  This is on IE 7 for your notes.

Thanks.