打擾一下
我最近在學javascript
看網路教學後綜合做了一個select和radio有加減的函式
但一直沒成功
也找不到錯在哪裡
請大大們指點指點
大意為checked*selected+input1輸入之數值=輸出到input2
以下為程式碼
<html>
<head>
<title></title>
<script>
function _click(theform){
var rl = theform._radio.length;
var sl = theform._select.option.length;
for(var i=0;i<rl;i++)
{
if(theform.radio[i].checked)
{
var rv = theform._radio[i].value;
}
}//radio
for(var i=0;i<sl;i++)
{
if(theform._select.option[i].selected)
{
var sv = theform._select.option[i].value;
}
}//select
var inpva = parseInt(document.getElementById("_input1").value;)
var aaaa= parseInt(sv*rv);
document.getElementById("_input2").value= aaaa+inpva ;
}
</script>
</head>
<body>
<form>
<input type="radio" name="_radio" value="10">10</input>
<input type="radio" name="_radio" value="20">20</input>
<select name="_select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="text" name="_input1" id="_input1">
<button type="reset" value="">清除</button>
<button onclick="_click(this.form)">=</button>
<input type="text" readonly="true" name="_input2" id="_input2">
</form>
</body>
</html>