我試圖用多個(滑塊)貝寶爲了製作一個動態按鈕,其價格值根據滑塊值而變化。發送由<input type =「range」>(滑塊)計算的變量爲PayPal按鈕的價格值<input type =「hidden」name =「amount」>
到目前爲止,我已經設法將計算出的值作爲javascript中的變量(var = mapoman)。但是我一直未能將價值傳遞給PayPal按鈕...我正在使用一個無託管的PayPal按鈕。
我假設計算值存儲在輸入中,對嗎? 目前在窗體輸入計算通過輸出和功能顯示Add()計算的值爲貝寶按鈕...
我不能使用PHP,因爲我的服務器目前無法處理它。所以我試圖實現這隻使用JavaScript。
以下是我的代碼.. 我真的很希望它是可行的! 我感謝任何建議,謝謝!
<html>
<head>
<script language="javascript">
function Add(){
document.mapo.mapoprice.value = eval(document.mapo.slider1.value) + eval(document.mapo.slider2.value) + eval(document.mapo.slider3.value) + eval(document.mapo.slider4.value) + eval(document.mapo.slider5.value) + eval(document.mapo.slider6.value) + eval(document.mapo.slider7.value) + eval(document.mapo.slider8.value);
}
function GetMapoman(){
var mapoman = document.getElementById("mapoprice").value;
document.getElementById("saru").innerHTML = mapoman;
}
</script>
</head>
<body>
<form name="mapo" oninput="total.value = slider1.valueAsNumber + slider2.valueAsNumber + slider3.valueAsNumber + slider4.valueAsNumber + slider5.valueAsNumber + slider6.valueAsNumber + slider7.valueAsNumber + slider8.valueAsNumber;Add();GetMapoman();">
<input name="slider1" id="slider1" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider2" id="slider2" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider3" id="slider3" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider4" id="slider4" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider5" id="slider5" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider6" id="slider6" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider7" id="slider7" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input name="slider8" id="slider8" type="range" min="3" max="8" value="3" step="1" style="width:650px">
<input type="text" name="mapoprice" id="mapoprice"><!-- <--is this storing the value calculated by the sliders above???-->
<output name="total" for="slider1 slider2 slider3 slider4 slider5 slider6 slider7 slider8"></output>
</form>
<p id="saru"></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="---.com">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="item_name" value="---">
<input type="hidden" name="amount id="totalmapo"><!--this bit I'm trying to put the calculated value by the sliders-->
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
</body>
</html>
你在這裏面臨什麼問題? – Vimalnath 2014-09-26 09:23:44
嗨,問題是我無法將滑塊計算的值傳遞給paypal的價值(價格)。我一直在嘗試很多在stackoverflow中建議的方法,但還沒有設法找出它... – awishiki 2014-09-26 09:29:11
你可以檢查答案 – Vimalnath 2014-09-26 10:09:49