# JS Variable + Form Field

**URL:** <https://forums.realmacsoftware.com/t/js-variable-form-field/8602>\
**Category:** RapidWeaver Classic\
**Created:** [July 17, 2016, 3:04pm UTC](https://forums.realmacsoftware.com/t/js-variable-form-field/8602 "2016-07-17T15:04:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrandonCorlett](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@BrandonCorlett](https://forums.realmacsoftware.com/u/BrandonCorlett)\
**Post date:** [July 17, 2016, 3:04pm UTC](https://forums.realmacsoftware.com/t/js-variable-form-field/8602/1 "2016-07-17T15:04:12Z")

</div>

I have some JavaScript on my page which contains a variable.

The script is run on a click event.

I would like to have a form field that allows for a visitor to input a value for the variable before running the script.

I’ve been search around for a solution, but nothing I’ve found appears to be the answer.

Anyone have any tips for what I should be googling?

Cheers,

Brandon

---

<div class="post-metadata">

**Author:** ![swilliam](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/swilliam/32/14799_2.png) [@swilliam](https://forums.realmacsoftware.com/u/swilliam)\
**Post date:** [July 17, 2016, 3:27pm UTC](https://forums.realmacsoftware.com/t/js-variable-form-field/8602/2 "2016-07-17T15:27:36Z")

</div>

I’m not sure I’m following you correctly but basically you want to have a one field form that then runs a script (like you would run a validation script) onsubmit ? Similar to this?  
``` ,

---

<div class="post-metadata">

**Author:** ![BrandonCorlett](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@BrandonCorlett](https://forums.realmacsoftware.com/u/BrandonCorlett)\
**Post date:** [July 17, 2016, 3:51pm UTC](https://forums.realmacsoftware.com/t/js-variable-form-field/8602/3 "2016-07-17T15:51:05Z")

</div>

The part of the script that needs the variable looks like this.

`$(".myButton").click (function(){ $.post( "https://www.url.com", { "value1" : "FORM_VARIABLE"} ); });`

I imaging having a form field who’s value will be populated as the `value1`
