用img onclick调用函数

来源:百度知道 编辑:UC知道 时间:2024/05/30 04:18:40
<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()
{
document.test1.value = successful.
}
//-->
</script>
</head>

<body>
<TABLE>
<TR>
<TD><IMG src="images/current1.gif" alt="Question 1" name="t1" width="31" height="31" id="1" onClick="test()"></TD>
</TR>
</TABLE>
<input name="test1" id="t1" type="text" value="" />
</body>
</html>

我希望按了img之后就能在text里面显示succ

<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()
{
var text = document.getElementById("t2");
text.value = "successful.";
}
//-->
</script>
</head>

<body>
<TABLE>
<TR>
<TD><IMG src="images/current1.gif" alt="Question 1" name="t1" width="31" height="31" id="1"

onClick="test()"></TD>
</TR>
</TABLE>
<input name="test2" id="t2" type="text" value="" />