我正在尝试设置多页捐赠表单。我已经设置好了,用户可以从几个不同的盒子中选择,这些盒子里面都有不同的金额。我想要的是它通过php会话变量将所选框的值传递到下一页。我有一个实际输入文本的输入框我觉得很好,但我无法弄清楚如何获得框的值。感谢。
<form role="form" action="donation.php">
<div class="donate-box col-xs-8 col-xs-offset-2">
<div class="donate-amounts">
<ul id="amounts">
<a href="#"><li>$15</li></a>
<a href="#"><li>$25</li></a>
<a href="#"><li>$50</li></a>
<a href="#"><li>$100</li></a>
<a href="#"><li>$200</li></a>
</ul>
</div><!-- End donate amounts -->
<div class="donate-other">
<div class="form-group">
<label for="otheramount">Other</label>
<input type="number" class="form-control" id="otheramount" placeholder="$" name="otheramount">
</div>
</div><!-- End donate other -->
<div class="donate-month">
<label for="monthly">Monthly</label>
<div id="donate-month-check" class="donate-checkbox check-blank">
<div id="month-check-on" style="display: none;"><img src="img/check.png"></div>
</div>
</div><!-- End donate month -->
<div class="donate-one-time">
<label for="one">One Time</label>
<div id="donate-one-check" class="donate-checkbox check-blank">
<div id="one-check-on" style="display: none;"><img src="img/check.png"></div>
</div>
</div><!-- End donate one time -->
<div class="donate-submit">
<button type="submit" class="btn btn-default donate-button">Donate Now</button>
</div>
</form>
$(function money () {
$('li').click(function () {
$('#amounts li').removeClass('clicked');
$('.donate-other').removeClass('clicked');
$(this).addClass('clicked');
});
$('.donate-other').click(function () {
$('#amounts li').removeClass('clicked');
$(this).addClass('clicked');
});
$('#donate-month-check').click(function () {
$('#one-check-on').hide();
$('#month-check-on').toggle();
});
$('#donate-one-check').click(function () {
$('#month-check-on').hide();
$('#one-check-on').toggle();
});
$('#amounts li').click(function() {
$('#otheramount').val('0');
})
});
答案 0 :(得分:0)
<div class="donate-amounts">
<ul id="amounts">
<a href="your_url?amount=15"><li>$15</li></a>
your_url.php
($_GET["amount"])
答案 1 :(得分:0)
您可以通过GET请求传递数据:
<div class="donate-amounts">
<ul id="amounts">
<a href="page.php?quantity=15"><li>$15</li></a>
<a href="page.php?quantity=25"><li>$25</li></a>
<a href="page.php?quantity=50"><li>$50</li></a>
<a href="page.php?quantity=100"><li>$100</li></a>
<a href="page.php?quantity=200"><li>$200</li></a>
</ul>
然后在page.php中获取数量变量:
<?
$quantity = $_GET['quantity'];
?>
答案 2 :(得分:0)
$('#amounts li').click(function() {
$('#otheramount').val($(this).text());
})