我正在使用django创建信用卡付款页面。用户可以选择填写信用卡信息或使用以前输入的卡。但是,用户必须选择一个位置。
有没有办法创建表单,所以我不必有2个单独的位置“选择”按钮?
HTML:
<h1>Charge $10 with Stripe</h1>
<!-- to display errors returned by createToken -->
<span class="payment-errors"></span>
<form action="" method="POST" id="payment-form">
{% csrf_token %}
{% if not user.is_authenticated %}
<div class="form-row">
<label>Full Name</label>
<input type="text" size="30" autocomplete="off" name="fullname" />
</div>
<div class="form-row">
<label>Email</label>
<input type="text" size="30" autocomplete="off" name="email" />
</div>
<div class="form-row">
<label>Phone</label>
<input type="text" size="11" autocomplete="off" name="phone" />
</div>
{% endif %}
<label>Location</label>
<select name="location">
<option value="muir">Muir</option>
<option value="erc">ERC</option>
<option value="marshall">Marshall</option>
<option value="warren">Warren</option>
<option value="revelle">Revelle</option>
<option value="sixth">Sixth</option>
</select>
<div class="form-row">
<label>Card Number</label>
<input type="text" size="20" autocomplete="off" class="card-number" />
</div>
<div class="form-row">
<label>CVC</label>
<input type="text" size="4" autocomplete="off" class="card-cvc" />
</div>
<div class="form-row">
<label>Expiration (MM/YYYY)</label>
<input type="text" size="2" class="card-expiry-month"/>
<span> / </span>
<input type="text" size="4" class="card-expiry-year"/>
</div>
{% if user.is_authenticated %}
<input type="checkbox" name="save_card_info" value="yes"/> Save this card </br>
{% endif %}
<button type="submit" class="submit-button">Submit Payment</button>
</form>
{% if user.is_authenticated and user.get_profile.stripe_customer_id %}
</br>
OR:
</br>
</br>
Use card ending with: 4343
<form action="" method="POST">
{% csrf_token %}
<label>Location</label>
<select name="location">
<option value="muir">Muir</option>
<option value="erc">ERC</option>
<option value="marshall">Marshall</option>
<option value="warren">Warren</option>
<option value="revelle">Revelle</option>
<option value="sixth">Sixth</option>
</select>
</br>
<input type="hidden" name="action=" value="pay_saved_card"/>
<button type="submit">Submit Payment</button>
</form>
{% endif %}
</body>
答案 0 :(得分:0)
您可以在相应表单的提交事件处理程序中通过JavaScript(在使用jQuery时可能非常容易)检索所选位置。