Skip to content

Instantly share code, notes, and snippets.

@noahub
Created November 5, 2015 19:02
Show Gist options
  • Save noahub/cd1c92625f9fc6d0bbed to your computer and use it in GitHub Desktop.
Save noahub/cd1c92625f9fc6d0bbed to your computer and use it in GitHub Desktop.
Populate form field value based on different button clicks
//Update the button IDs (e.g. '#lp-pom-button-126') with your own button IDs, 'your_field_name' with your form's field name, and the value (e.g. 'Intro') with your own values.
<script type="text/javascript">
$(document).ready(function () {
$("#lp-pom-button-126").click(function(){
$("#lp-pom-form-363 input[name=your_field_name]").val("Intro");
});
$("#lp-pom-button-136").click(function(){
$("#lp-pom-form-363 input[name=your_field_name]").val("Silver");
});
$("#lp-pom-button-146").click(function(){
$("#lp-pom-form-363 input[name=your_field_name]").val("Gold");
});
$("#lp-pom-button-166").click(function(){
$("#lp-pom-form-363 input[name=your_field_name]").val("Platinum");
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment