I am trying to set the value of a parameter of a <script>
element using a Javascript value. Using the Stripe checkout.js it is possible to set the value of the Email box using a parameter, and where it asks for the users email is somewhere else on the page, so I need to grab the value of that text box and send it to that parameters value, like so:
<form action="charge.php" method="post">
<center>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input class="form-control" id="inputEmail" name="inputEmail" type="text" maxlength="64" data-validation="email" placeholder="donator@example.com">
</div>
</div><br><br>
<input type="range" min="1" max="100" value="5" step="1" name="inputAmount" id="inputAmount" onchange="updateBox(this.value)">
<span class="pull-right"><input type="tel" maxlength="3" id="inputAmountText" name="inputAmountText" class="form-control" value="5" onchange="updateSlider(this.value)"></span>
</center>
<br><br><br>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-description="Donation"
data-email="$('#inputEmail').val();"
data-image="https://joshstroup.me/global/img/avatar.png"
data-name="Joshua Stroup"
data-zip-code="true"
data-panel-label="Donate"
data-label="Proceed To Payment"></script>
</form>
Notice where I am setting data-email
to $('#inputEmail').val();
, this is how (I think) it is done, but when I open the checkout form the box is blank with the placeholder showing, so I'm not quite sure how to set it properly.