on 2005 Feb 10 11:44 AM
Hi All,
<b>My requirement:</b>On an DateField (CL_HTMLB_INPUT ), if you select a datepicker and select a value, I need a server roudtrip i.e submit of the form.
<b>Code changes I did:</b>with the javascript, I added a code ,
lv_dateField.attachEvent('onchange', function(){
htmlbSubmitLib('htmlb',this,'htmlb:inputField:click:null',lv_formName,lv_dateFieldId,'submitonenter',0);
return false;
});
<b>Result:</b>If I manually change the field and move away from the datefield 'onchange' event is triggered.
<b>Unsolved problem:</b>
If I use Datepicker and select a new value , and move from the fields i.e change focus 'onchange' event is not triggered.
Your help is highly appreciated.
regards,
Vijaya Kumar M.
Request clarification before answering.
Have you tried attaching the onkeyup, onkeypress or blur event instead of the onchange? onchange requires the user to leave the field first.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You would have to save the current value in a hidden form field then in a javascript method check it against the value in your datepicker field then if it's not the same then you would have to submit the form.
Not much else of a chance since you want to do this local.
So on loading the page have a field type hidden (normal HTML form field) that you place the value in along with placing it in your datepicker htmlb:inputField then fire your onchange javascript event and compare the hidden field to the actual field then submit like normal if it's different.
I will for the moment ignore that JavaScript code to fire the event library. Enough has been said on this topic.
For the question of changed value, see previous append of mine tonight. You can do some reading on the attribute defaultValue for an input field. From my understanding this is the value that the inputField had when the document was first loaded. So with this, you should be able to test whether you have a new value or not.
Hi Brain,
Thanks a lot for your reply.
Attached is the code I used , It works perfectly.
lv_dateField.attachEvent('onblur', function(){
if((lv_dateField.value) != (lv_dateField.defaultValue))
{
htmlbSubmitLib('htmlb',this,'htmlb:inputField:click:null',lv_formName,DateFieldId,'submitonenter',0);
return false;
}
lv_dateField.defaultValue = lv_dateField.value;
});
<b>I'm left out with one last question,</b>
What event should I need to capture datepicker selection ?
Right now 'onblur' will work only once I change the focus to other field.
regards,
Vijaya Kumar M.
Message was edited by: Vijaya Kumar
Hi Brian and Craig,
Thanks a lot for your inputs. My problem is solved.
Roundtrip works when I use the datepicker.
Following is the code I used.
<b>I)</b> Datepicker after the date selection , it puts the focus onto the InputFiled. I used the 'onfocus' event to do the server roundtrip.
lv_dateField.attachEvent('onfocus', function(){
if((lv_dateField.value) != (lv_dateField.defaultValue))
{
htmlbSubmitLib('htmlb',this,'htmlb:inputField:click:null',lv_formName,DateFieldId,'submitonenter',0);
}
lv_dateField.defaultValue = lv_dateField.value;
});
<b>II)</b> If you manually change and move away from the Datefield, to avoid the server round trip, I re-setted the
defaultValue to the CurrentValue.
lv_dateField.attachEvent('onblur', function(){
lv_dateField.defaultValue = lv_dateField.value;
});
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.