DesiLogi Posted March 4, 2017 Report Share Posted March 4, 2017 Does anyone know the adjustment for this code to work? I'm trying to copy the value of a Virtual field (drop down) to a regular text field, on a button's click. Here's the code I'm working with: <div style="text-align: center;"> <input class= "cb_custom_btn" type="submit" onclick="myfunction()" value="Submit" /> <script> function myfunction() { var virtualval = document.getElementByID("cbParamVirtual4").value; document.getElementByID("InsertRecordMyFieldName").value = virtualval; } </script> </div> I'd also tried the ElementsByName with [0] for cascading values but that doesn't work either.. What's weird is I've used code similar to this for the same purpose with no problem so I must be missing some minute detail. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Mathilda Posted March 6, 2017 Report Share Posted March 6, 2017 On 3/4/2017 at 9:09 AM, DesiLogi said: Does anyone know the adjustment for this code to work? I'm trying to copy the value of a Virtual field (drop down) to a regular text field, on a button's click. Here's the code I'm working with: <div style="text-align: center;"> <input class= "cb_custom_btn" type="submit" onclick="myfunction()" value="Submit" /> <script> function myfunction() { var virtualval = document.getElementByID("cbParamVirtual4").value; document.getElementByID("InsertRecordMyFieldName").value = virtualval; } </script> </div> I'd also tried the ElementsByName with [0] for cascading values but that doesn't work either.. What's weird is I've used code similar to this for the same purpose with no problem so I must be missing some minute detail. Any help would be greatly appreciated. I would recommend separating html and java script. Also you should use getElementById instead of getElementByID. Try using html code in html block: <div style="text-align: center;"> <input type="submit" onclick="myfunction()" value="Submit" /> </div> And the following script in the footer: <script> function myfunction() { var virtualval = document.getElementsByName("cbParamVirtual4")[0].value; document.getElementById("InsertRecordMyFieldName").value = virtualval; } </script> Quote Link to comment Share on other sites More sharing options...
DesiLogi Posted March 6, 2017 Author Report Share Posted March 6, 2017 Hi Mathilda, Thanks very much for the help with that- it works nicely. That said, the function I'm trying to work out as morphed since I posted this- I've put it on a different page, if you'd like to take a look. This thread was a question on a specific part of what I'm trying to do- as I've found other limitations (of my own ability with js) I've tried to lay out the whole process there. 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.