Jump to content
  • 0

Fill text fields with existing info if the checkbox is check


MayMusic
 Share

Question

I have a submission page that users need to fill their shipping and billing address. I want to have a checkbox (same address as shipping) and if they check that checkbox automatically fill billing address fields with the same data in shipping address fields. Any help would be appreciated.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0
Please try this code in an HTML block at the very end of the element list or in the footer:

 

 



<script>
function f_address()
{
    if(document.getElementById('cbParamVirtual1').checked)
    {
  document.getElementById('InsertRecordBilling_Address').value=document.getElementById('InsertRecordShipping_Address').value;
document.getElementById('InsertRecordBilling_City').value=document.getElementById('InsertRecordShipping_City').value;
document.getElementById('InsertRecordBilling_State').value=document.getElementById('InsertRecordShipping_State').value;
document.getElementById('InsertRecordBilling_zip').value=document.getElementById('InsertRecordShipping_zip').value;
} else {
document.getElementById('InsertRecordBilling_Address').value="";
document.getElementById('InsertRecordBilling_City').value="";
document.getElementById('InsertRecordBilling_State').value="";
document.getElementById('InsertRecordBilling_zip').value="";
}


}
document.getElementById('cbParamVirtual1').onclick= f_address;
</script>


 

Please note in here you need to replace cbParamVirtual1 with the ID of the checkbox and all other field IDs with the appropriate ID you have in your form. 

 

I have one suggestion since you are using Java Scripts. Use Firefox and install Firebug which is an add-on for Firefox, free and open source. It allows the debugging, editing, and monitoring of any website's CSS, HTML, DOM, and JavaScript, and provides other Web development tools. It also has a JavaScript console for logging errors and watching values, as well as a "Net" feature which monitors the amount of time in milliseconds it takes to execute scripts and load images on the page. I am also using Firebug to get the ID of an element.

 

Cheers   :)   :)

Link to comment
Share on other sites

  • 0

Maby one of you can help me to use this javascript on a "Tabular Report" instead of a "SubmissionForm".

I changed "Insert" for "edit" in the lines document.GetElementByID, but it won't work.

I use this script:

function f_address()

{

if(document.GetElementById('cbParamVirtual2').checked)

{

document.getElementById('EditRecordOrderQuantity_SC').value=document.getElementById('EditRecordQuantity').value;

}

else {

document.getElementById('EditRecordOrderQuantity_SC').value="";

}

}

document.getElementById('cbParamVirtual2').onclick= f_address;

John

Link to comment
Share on other sites

  • 0

If you can provide me the link of the page I can give you all the IDs, so you can replace. I use firebug to inspect the code https://getfirebug.com/

Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page and also inspect the source code to get the ID of the elements. :!: :!:

Link to comment
Share on other sites

  • 0

Thanks for your reply,

I solved the problem with an other script that i have used, and this works for me:

function f_address()

{

if(document.getElementById('EditRecordOrder_SC').checked)

{

document.getElementById('EditRecordOrderQuantity_SC').value=document.getElementById('EditRecordQuantity').value;

}

else {

document.getElementById('InsertRecordOrderQuantity_SC').value="x";

}

}

document.getElementById('EditRecordOrder_SC').onclick= f_address;

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
Answer this question...

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