Jump to content

Recommended Posts

Hello Im using the following code:

 

<script>
document.getElementById('InsertRecordVisit_Type').onchange = function () {{

var currentdate = new Date();
var datetime = (currentdate.getMonth()+1) + "/"
                + currentdate.getDate()  + "/"
                + currentdate.getFullYear() + " "  ;
document.getElementById('InsertRecordDate').value = datetime;
document.getElementById('InsertRecordAccessory_1').value = "Cord";

}}
</script>

 

All is working fine except I cannot get the Accessory_1 value to change - this is a dropdown field that is the parent field for and autocomplete field.   what do I need to add to get the parent field to accept the instructions ?

 

Thanks!!!

Link to comment
Share on other sites

Hi Braxwell,

For dropdowns and AutoComplete form elements, Caspio attach a hash value to the ID, making it impossible to access them via document.getElementById(). The correct way to access them is via document.getElementsByName(FIELD_NAME)[0].

As such, I have updated the codes for both InsertRecordVisit_Type (parent dropdown) and InsertRecordAccessory_1 (AutoComplete) fieldsThe updated code should now look like this:

<script>
document.getElementsByName('InsertRecordVisit_Type')[0].onchange = function ()  {
var currentdate = new Date();
var datetime = (currentdate.getMonth()+1) + "/"
                + currentdate.getDate()  + "/"
                + currentdate.getFullYear() + " "  ;
document.getElementById('InsertRecordDate').value = datetime;
document.getElementsByName('InsertRecordAccessory_1')[0].value = "Cord";
}
</script>

Hope this helps.

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
Reply to this topic...

×   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...
 Share

×
×
  • Create New...