有多个按钮 1-9等等 如何用js实现点击按钮将按钮的ValuE的值传到文本框
``<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function test(str)
{
var x=document.getElementById("one").value;
var y=document.getElementById("two").value;
var t1;
switch(str)
{case "+":t1=parseInt(x)+parseInt(y);break;
case "-":t1=parseInt(x)-parseInt(y);break;
case "*":t1=parseInt(x)*parseInt(y);break;
case "/":t1=parseInt(x)/parseInt(y);
}
document.getElementById("result").value=t1;
}
</script>
</head>
<body>一个数:<input type="text" id="one"><br/>
另一个数:<input type="text" id="two"><br/>
结果:<input type="text" id="result"><br/>
<input type="button" value="+" onclick="test('+')"/><input type="button" value="-" onclick="test('-')"/><input type="button" value="*" onclick="test('*')"/><input type="button" value="/" onclick="test('/')"/>
</body>
</html>
`
定义函数function test(str)实现单击onclik中的“test("+")”“test("-")”“test("*")”“test("/")”