Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Graham on Apr 03, 2009 03:32
open dhtmlx forum
DHTMLXCOMBO box often submits the default value

I have a dhtmlxcombo box which accepts text entry or drop-down selection.  Beneath this dhtmlxcombo box is the submit button.  Users are entering a value in the dhtmlxcombo box (e.g. 1400)... as soon as they've typed the last character they are clicking on the submit button.   They do not click outside of the dhtmlxcombo box or 'tab away' from it in any way before clicking the Submit button.  Therefore the value they've entered in the dhtmlxcombo box isn't being registered before the submit takes place.   Instead, the default value of the dhtmlxcombo box gets submitted instead.

The process works fine for those users who click outside of the dhtmlxcombo box or 'tab away' from it before clicking the submit button.   But I cannot rely on that.

Please could someone suggest a way of getting around this problem - with code examples would be great.

A snippit from my existing ASP/Javascript code is as follows...

<script>
   z4.setComboValue(0000);    
   z4.setComboText('- finish time -');
   z4.enableOptionAutoHeight(1);
   z4.attachEvent("onOpen",function(){z4.setComboText(""); return true;});
   z4.attachEvent("onKeyPressed",onTimeOutKeyPressedFunc);
   function onTimeOutKeyPressedFunc(kp){check24hrs(kp,z4);};
   z4.attachEvent("onSelectionChange",onTimeOutSelectionChangeFunc);
   function onTimeOutSelectionChangeFunc(){if (z4.getSelectedValue() != z3.getSelectedValue()){z3.setComboValue(z4.getSelectedValue());};};   
   z4.attachEvent("onBlur",onTimeOutBlurFunc);
    function onTimeOutBlurFunc(){if (z4.getComboText().length <4){z3.setComboValue(0000);z4.setComboValue(0000);}}
  </script>

<input name="Submit4" type="submit" onClick="YY_checkform('form2','Day','#q','1','Please select valid Day');return document.MM_returnValue" value="Save Attendance Information">

 

Thanks,

Graham.

Answer posted by Alex (support) on Apr 03, 2009 05:44

 You can try to call confirmSelection() method before form submit:

<form onsubmit="z4.confirmSelection()" ...

Answer posted on Apr 03, 2009 07:44

Thanks for the suggestion.

I just tried it but I can't seem to get that z4.confirmSelection() to work.  Exactly what should the syntax be in the context of my existing code?

 

Answer posted by Alex (support) on Apr 03, 2009 10:31

Sorry for the misleading information. 

It was my typo.

The correct method name is _confirmSelection:

z4._confirmSelection(); /*where z4 is combo object*/

Answer posted by Graham on Apr 06, 2009 03:55

That's fantastic - thanks very much.

I thought it was going to give me a prompt to 'sonfirm selection' but instead it just confirms the selection itself before proceeding with the submit which is exactly what I was after :o)

Cheers,

Graham.