cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

I need Server Roundtrip on Datepicker selection.

vijayakm
Product and Topic Expert
Product and Topic Expert
0 Kudos
373

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.

View Entire Topic
Former Member
0 Kudos

Have you tried attaching the onkeyup, onkeypress or blur event instead of the onchange? onchange requires the user to leave the field first.

vijayakm
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Craig,

Yes you are right!!. I did this with the 'onblur' event , this event get triggers. But due to performance reason, <b>I want to trigger "server round trip" only if the content in the field is changed.</b>

thanks & regards,

Vijaya Kumar M.

Former Member
0 Kudos

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.

former_member181879
Active Contributor
0 Kudos

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.

vijayakm
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

Thanks Brian! That is a nice feature!

Unless Brian has another thought on the datapicker selection I think you'll have to revert back to the previous replies.

vijayakm
Product and Topic Expert
Product and Topic Expert
0 Kudos

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;

});

Former Member
0 Kudos

Excellent and thanks for the steps there I'm sure they'll help others out in the future.