[英]Get value of selected div and carry to the next page with php
我試圖建立一個多頁捐贈表格。 我已經設置好了,用戶可以從幾個不同的盒子中進行選擇,每個盒子中都有不同的金額。 我想要的是通過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');
})
});
<div class="donate-amounts">
<ul id="amounts">
<a href="your_url?amount=15"><li>$15</li></a>
your_url.php
($_GET["amount"])
您可以通過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'];
?>
這是你想要的嗎? 這是我創建的小提琴: http : //jsfiddle.net/56BCe/
$('#amounts li').click(function() {
$('#otheramount').val($(this).text());
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.