ChristofK Posted August 23, 2016 Report Share Posted August 23, 2016 Hi everyone, I'm fairly new to the world of JavaScript and have the following scenario on a submission page: During submission, my users select a business client using an AutoComplete field. Once they selected a client, two virtual fields pull two values for this client from an external table. These lookups are set up using cascading text field. On the same DataPage, there is a radio button with two options. Should the two virtual fields remain blank (basically meaning that there is no value for either of the fields for this client in the external table), the 2nd radio button option should be selected and the field hidden to prevent user interaction. The hiding and selection part works fine, but it seems that I'm not able to get the value from the virtual fields and my script stops working as soon as I add the condition that involves the value of any of the two virtual fields: <script type= "text/javascript"> function AMFCheck() { var AMF1 = document.getElementById('cbParamVirtual12')[0].value; var AMF2 = document.getElementById('cbParamVirtual13')[0].value; if (AMF1 == "" && AMF2 == "" ) { document.getElementById("InsertRecordAMF_payable1").checked = true; document.getElementById("InsertRecordAMF_payable").style.display = "none"; } } document.getElementById("caspioform").onchange=AMFCheck; </script> I'd be really grateful for any help. Thanks, Christof Quote Link to comment Share on other sites More sharing options...
LWSChad Posted August 24, 2016 Report Share Posted August 24, 2016 Cascading fields lose their static ID, so if it's a cascading text field the ID will change from "cbParamVirtual12" to something like "cbParamVirtual12_jhdas068fsda0t67f8" Try var AMF1 = document.getElementsByName('cbParamVirtual12')[0].value; rather than var AMF1 = document.getElementById('cbParamVirtual12')[0].value; ChristofK 1 Quote Link to comment Share on other sites More sharing options...
ChristofK Posted August 25, 2016 Author Report Share Posted August 25, 2016 Dear EIQ, Thank you so much for your help, it works perfectly now. Best, Christof Quote Link to comment Share on other sites More sharing options...
LWSChad Posted August 30, 2016 Report Share Posted August 30, 2016 Glad it helped! When you choose a best answer, this will leave the list of unanswered questions. Thank You Quote Link to comment Share on other sites More sharing options...
Teshan Posted May 11, 2017 Report Share Posted May 11, 2017 On 8/25/2016 at 5:12 AM, ezIQchad said: Cascading fields lose their static ID, so if it's a cascading text field the ID will change from "cbParamVirtual12" to something like "cbParamVirtual12_jhdas068fsda0t67f8" Try var AMF1 = document.getElementsByName('cbParamVirtual12')[0].value; rather than var AMF1 = document.getElementById('cbParamVirtual12')[0].value; This is not working for cascading virtual text fields Thank you Quote Link to comment Share on other sites More sharing options...
kpcollier Posted November 29, 2018 Report Share Posted November 29, 2018 Hey, @ezIQchad. Any chance you're still active? I am having an issue similar to this. I was having a problem passing parameters interally to a popup, and because of this post I found its because Cascading Fields lost their static id. However, I believe the code I am using is using ID selectors and I am not sure how to change it to name. (I think its jQuery) Quote Link to comment Share on other sites More sharing options...
AveEd Posted July 20, 2022 Report Share Posted July 20, 2022 On 8/24/2016 at 3:12 PM, LWSChad said: Cascading fields lose their static ID, so if it's a cascading text field the ID will change from "cbParamVirtual12" to something like "cbParamVirtual12_jhdas068fsda0t67f8" Try var AMF1 = document.getElementsByName('cbParamVirtual12')[0].value; rather than var AMF1 = document.getElementById('cbParamVirtual12')[0].value; Can you copy past the full code and correct it for us? Quote Link to comment Share on other sites More sharing options...
Meekeee Posted July 22, 2022 Report Share Posted July 22, 2022 Hi @AveEd - you can use querySelector. Here are some examples: document.querySelector("input[name='cbParamVirtual1']") OR document.querySelector("input[id*='cbParamVirtual1']") OR document.querySelector("[name='cbParamVirtual1']") For more information, you can check this link: https://www.w3schools.com/jsref/met_document_queryselector.asp 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.