[問題] 請問我想用javsscript做加法運算
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>123</title>
<script language="javascript">
function myfunc(){
var s1=document.form1.t1.value;
var s2=document.form1.t2.value;
s3=s1+s2
s4=s1%s2
alert("數字1+數字2="+s3+","+"餘數="+s4);
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p> </p>
<table border="1">
<tr>
<td>數字1:</td>
<td><input name="t1" type="text" id="t1" /></td>
</tr>
<tr>
<td>數字2:</td>
<td><input name="t2" type="text" id="t2" /></td>
</tr>
</table>
<p>
<input type="button" name="b1" id="b1" value="ok" onClick="myfunc()"/>
</p>
<p> </p>
</form>
<p> </p>
</body>
</html>
以上是我的程式碼~
可是當網頁出來後,自行設兩個數但都不會等於加法
例如:我第一個數字輸入9第二個數字輸入4他不會等於13
它會顯示成94.....
有人知道該如何解決嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.165.234.118
※ 編輯: ying0902 來自: 118.165.234.118 (03/14 18:36)
推
03/14 18:52, , 1F
03/14 18:52, 1F
→
03/14 18:53, , 2F
03/14 18:53, 2F
→
03/14 18:53, , 3F
03/14 18:53, 3F
→
03/14 19:08, , 4F
03/14 19:08, 4F
→
03/14 19:53, , 5F
03/14 19:53, 5F
推
03/14 20:38, , 6F
03/14 20:38, 6F
→
03/14 20:39, , 7F
03/14 20:39, 7F