我有一个页面,允许用户选择表单中的一些东西,它会使用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