Jump to content

Button to Copy Data from One Field to Another


Recommended Posts

How would I change this code to pull data from an existing data field and place that value in another field?

 

script>
function onSubmitClick() {
var box1 = document.getElementById('box1');
var box2 = document.getElementById('box2');
box2.value = box1.value;
}
</script>

<textarea id='box1'></textarea>
<textarea id='box2'></textarea>
<button onclick='onSubmitClick(); return false'>Click Me</button>

Link to comment
Share on other sites

Do you want to change it to Caspio format? Is it on a submission page? In submission pages IDs are in this format: InsertRecordFIELDNAME

 

So you need to have

<script>
function onSubmitClick() {
var box1 = document.getElementById('InsertRecordFILEDONE');
var box2 = document.getElementById('InsertRecordFILEDTWO');
box2.value = box1.value;
}
</script>

<button onclick='onSubmitClick(); return false'>Click Me</button>

 

Replace InsertRecordFILEDONE and InsertRecordFILEDTWO with the actual ID. To get the ID you can also right click on the element and from the window that opens select inspect element

 

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...
 Share

×
×
  • Create New...