braxwell Posted January 9, 2017 Report Share Posted January 9, 2017 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!!! Quote Link to comment Share on other sites More sharing options...
nightowl Posted January 10, 2017 Report Share Posted January 10, 2017 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) fields. The 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. Quote Link to comment Share on other sites More sharing options...
braxwell Posted January 12, 2017 Author Report Share Posted January 12, 2017 Ok - I understand - Ill give this a try - Thank You~! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.