Jump to content

How to duplicate a field within a form


Recommended Posts

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?

Link to comment
Share on other sites

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.

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...
×
×
  • Create New...