Skip to content

Instantly share code, notes, and snippets.

@Barrytron1983
Created August 8, 2014 10:05
Show Gist options
  • Save Barrytron1983/ebd7bf15bef884231214 to your computer and use it in GitHub Desktop.
Save Barrytron1983/ebd7bf15bef884231214 to your computer and use it in GitHub Desktop.
Automatically fill a form field with text from another field using checkbox :: JS/Wordpress/Contact Form 7
/* Header: */
<script type="text/javascript">
function FillBilling(f) {
if(f.billingtoo.checked == true) {
f.invoice_textarea.value = f.deliveryaddress.value;
}
}
</script>
/* in the form - using Contact Form 7 */
<p>Delivery Address <span style="color: #ff0000">*</span></p>
[textarea* textarea-572 id:deliveryaddress class:input-text]
<input type="checkbox" name="billingtoo" onclick="FillBilling(this.form)">
<em>Check this box if Invoice Address and Delivery Address are the same.</em><br>
<p>Invoice Address <span style="color: #ff0000">*</span></p>
[textarea* textarea-252 id:invoice_textarea class:input-text]
<br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment