mferguson Posted September 2, 2011 Report Share Posted September 2, 2011 I need to duplicate a field that a user inputs within the same form in a hidden field. Parameters don't seem to work for this because it's within the same form. There was a script posted in the forum to do this kind of thing some time ago, but it doesn't seem to work: var temp = document.getElementById("copy from field").value; document.getElementById("copy to field").value = temp; Any ideas on why the script doesn't work, or is there a simpler solution to get done what I am trying to do? Quote Link to comment Share on other sites More sharing options...
ShWolf Posted September 2, 2011 Report Share Posted September 2, 2011 Hi, In the example you provided the code will be executed on page load. For example, you have a table with two fields: Field1 and Field2 (Field2 is hidden). If FIeld1 has static value (or receiving parameter), then you can use your script on page load: var temp = document.getElementById("InsertRecordField1").value; document.getElementById("InsertRecordField2").value = temp; But if you want the value to be copied on submit, you should use the following approach: document.getElementById('caspioform').onsubmit = function() { var temp = document.getElementById("InsertRecordField1").value; document.getElementById("InsertRecordField2").value = temp; } Place the code in the Footer. Hope this helps. Quote Link to comment Share on other sites More sharing options...
mferguson Posted September 2, 2011 Author Report Share Posted September 2, 2011 Yes, that script works great. Thanks! Also, thanks for explaining why that other code wasn't working for me. The additional mistake I was making was not having "InsertRecord" within the quotation marks with the field name. 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.