Hatena::Grouphtmlworld

Html First Step

 | 

2013-03-03

formの要素を配列にする方法(応用編)

12:05

<html>
<head>
<script language="javascript">
function calc(current_line) {
        var frm = document.frm_main;
        var start_value = frm.elements['start[]'][current_line].value;
        var end_value = frm.elements['end[]'][current_line].value;
        frm.elements['sum[]'][current_line].value = eval(start_value) + eval(end_value);

}
</script>
</head>
<body bgcolor="#efefef" link="#666699" alink="#666699" vlink="#666699" topmargin=0 bottommargin=0>
<table border=0 align="center" width="800px" cellspacing=0 cellpadding=0 bgcolor="#ffffff">
<tr>
<td>
<!-- campus start -->

<br>
<form name=frm_main method="post" action="index.php">
1 line
<input type="text" name="start[]" size="4" maxlength="4" onBlur="calc(0); return false;">
<input type="text" name="end[]" size="4" maxlength="4" onBlur="calc(0); return false;">
<input type="text" name="sum[]" size="4" maxlength="4" disabled>
<br> 
2 line
<input type="text" name="start[]" size="4" maxlength="4" onBlur="calc(1); return false;">
<input type="text" name="end[]" size="4" maxlength="4" onBlur="calc(1); return false;">
<input type="text" name="sum[]" size="4" maxlength="4" disabled>
</form>


<!-- campus end -->
</td>
</tr>  
</table>
</body>
</html>

iriqauyiriqauy2018/11/17 22:15http://doxycycline-cheapbuy.site/ - doxycycline-cheapbuy.site.ankor <a href="http://onlinebuycytotec.site/">onlinebuycytotec.site.ankor</a>

 |