我有一個頁面,允許用戶選擇表單中的一些東西,它會使用javascript計算重量。它將其分解成5個變量,我需要發送到另一個頁面。最初我只是把它放到一個文本框中,然後我發佈該文本框。但是我不想有5個文本框。所以現在我需要以某種方式發送或發佈五個變量到另一個頁面。這是我的javascript功能。我需要張貼weightBoxOne - weightBoxFive發送Javascript變量
js函數
function getWeight(){
var weightBoxOne;
var weightBoxTwo;
var totalWeight;
var box = .5;
var quantity = document.dhform.quantity.value;
var cardSize = document.dhform.cardSize.value;
if(cardSize == 0.0141){
if(quantity <= 1000){
weightBoxOne = (quantity * cardSize) + box;
totalWeight = weightBoxOne;
}else if(quantity > 1000 && quantity <= 2000){
weightBoxOne = (1000 * cardSize) + box;
weightBoxTwo = ((quantity - 1000) * cardSize) + box;
totalWeight = weightBoxOne + weightBoxTwo;
}else if(quantity > 2000 && quantity <= 3000){
weightBoxOne = (1000 * cardSize) + box;
weightBoxTwo = (1000 * cardSize) + box;
weightBoxThree = ((quantity - 2000) * cardSize) + box;
totalWeight = weightBoxOne + weightBoxTwo + weightBoxThree;
}else if(quantity > 3000 && quantity <= 4000){
weightBoxOne = (1000 * cardSize) + box;
weightBoxTwo = (1000 * cardSize) + box;
weightBoxThree = (1000 * cardSize) + box;
weightBoxFour = ((quantity - 3000) * cardSize) + box;
totalWeight = weightBoxOne + weightBoxTwo + weightBoxThree + weightBoxFour;
}else{
weightBoxOne = (1000 * cardSize) + box;
weightBoxTwo = (1000 * cardSize) + box;
weightBoxThree = (1000 * cardSize) + box;
weightBoxFour = (1000 * cardSize) + box;
weightBoxFive = ((quantity - 4000) * cardSize) + box;
totalWeight = weightBoxOne + weightBoxTwo + weightBoxThree + weightBoxFour + weightBoxFive;
}
}else if(cardSize == 0.00949){
if(quantity <= 4000){
weightBoxOne = (quantity * cardSize) + box;
totalWeight = weightBoxOne;
}else{
weightBoxOne = (4000 * cardSize) + box;
weightBoxTwo = ((quantity - 4000) * cardSize) + box;
totalWeight = weightBoxOne + weightBoxTwo;
}
}
document.rates.weight.value = totalWeight;
}
//-->
這是最初發布
<form action="getRates.php" name="rates" method="post" onSubmit="popupform(this, 'join')">
<table style="width: 216px">
<tr>
<td style="width: 115px; height: 49px;"><span class="style16">Weight</span><br/>
<input type="text" id="weight" name="weight" size="10" maxlength="4"/>
</td>
<td align="right" style="width: 68px; height: 49px;" valign="top"><span class="style16">Zip Code</span><br/>
<input type="text" id="zip" name="zip" size="10" maxlength="5"/>
</td>
</tr>
<tr>
<td style="width: 115px">
<input name="submit" type="submit" value="Get Rate Costs" style="width: 138px" />
剛剛成立了一個快速的JSON網絡服務和使用jQuery的崗位職能,或其他一些流行的Ajax框架的服務器上(jQuery是最好不過) – 2010-05-10 17:43:17
...你不能使用數組而不是'weightBoxNineThousand'嗎? – kennytm 2010-05-10 17:43:19
只有五個,但仍然不幫助我發佈 – shinjuo 2010-05-10 17:44:56