Jump to content
  • 0

Cascading AutoComplete


jhanajc

Question

Hi, 

 

Using the code below I am populating a text field on a submission form which is then used as a Parent Field on a Cascading AutoComplete Virtual field triggered when the Date field changes.

This technically works but I find that the AutoComplete field does not update immediately unless I physically visit the parent field and make a keystroke (say a type space at the end of the value).

How can I force the Cascading AutoComplete field to update immediately?

Thanks!

 

<script type="text/javaScript">

function concatenate()
{
mydate = document.getElementsByName("InsertRecordDate")[0].value;
document.getElementsByName("InsertRecordDate_With_ID")[0].value = list_id+mydate;
}

var list_id = document.getElementsByName("InsertRecordListing_ID")[0].value;
var mydate = document.getElementsByName("InsertRecordDate")[0].value;

document.getElementsByName("InsertRecordDate_With_ID")[0].value = list_id+mydate;

document.getElementsByName("InsertRecordDate")[0].onchange = concatenate;

</script>

 

Further information:  I suspect it might be that the onchange event is not triggering on the receiving field (Date_With_ID) because the value is being script updated and not manually typed.

Trying to find a way of forcing the change event to occur. Any advice appreciated thanks!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

The following code in bold has the desired effect. It triggers a change event on the field after it has been updated by script:

 

var changeEvent = document.createEvent("HTMLEvents");

function concatenate()
{
mydate = document.getElementsByName("InsertRecordDate")[0].value;
document.getElementsByName("InsertRecordDate_With_ID")[0].value = list_id+mydate;


changeEvent.initEvent("change", true, true);
document.getElementsByName("InsertRecordDate_With_ID")[0].dispatchEvent(changeEvent);

}

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...