0
我正在使用表單驗證和字段,並且沒有內聯事件處理。我無法找到如何傳遞整數值的示例,對其執行操作並將其傳遞到另一個字段。這就是我要對付的:如何將表單值傳遞給表單中的其他字段使用javascript
形式如下:
ITEM CONTAINER QUANTITY PRICE EXTENDEDCOST
Small Beer Bottle,Can ?? @3.99/ea ??
HTML BITS
<form action="#" method="get" name="orderForm" id="orderForm">
<table id="products">
<input name="qtySmall" id="qtySmall" type="text" size="4" maxlength="6" value="" />
<input name="extSmall" id="extSmall" type="text" size="10" maxlength="60" value="" />
的Javascript
window.onload = initForms;
function initForms()
{
document.getElementById("qtySmall").onfocus = detect;
document.getElementById("qtySmall").onchange = going_away;
document.getElementById("extSmall").value = passmyvalue; //not sure about this one yet
}
function detect()
{
alert("works")
}
function going_away()
{
pass_variable = document.getElementById("qtySmall").value;
}
function passmyvalue()
{
// I have no idea how to pass my qty small multiply it and pass it to the next field box 4 beers * 3.99 = 15.96 in extsmall
}
感謝您的幫助
這不是很清楚你想在這裏做什麼,只是輸入一些數量而不是計算擴展成本,對不對?如果是這種情況,你應該做一個onblur函數,它將獲得數量的值並且在相同的函數中進行計算。 – vaske 2010-02-15 19:43:45