<form action="index.php" method="post" target="_self"><input name="name" id="name" type="hidden" value="aaa" /><input type="submit" value="aaa" style="border:none;"></form>
<form action="index.php" method="post" target="_self"><input name="name" id="name" type="hidden" value="bbb" /><input type="submit" value="bbb" style="border:none;"></form>
<form action="index.php" method="post" target="_self"><input name="name" id="name" type="hidden" value="ccc" /><input type="submit" value="ccc" style="border:none;"></form>有三组按钮,分别传递值到当前页的指定标签<p>里面,替换原先的值。
比如打开index.php时,<p>标签显示为ddd,当按下aaa按钮时,<p>标签里的字被替换成aaa,当按下bbb按钮时,<p>标签里的字被替换成bbb,当按下ccc按钮时,<p>标签里的字被替换成ccc。
这个该怎样替换?<p>ddd<?php echo $_POST["name"]; ?></p>
<form action="index.php" method="post" target="_self"><input name="name" id="name" type="hidden" value="bbb" /><input type="submit" value="bbb" style="border:none;"></form>
<form action="index.php" method="post" target="_self"><input name="name" id="name" type="hidden" value="ccc" /><input type="submit" value="ccc" style="border:none;"></form>有三组按钮,分别传递值到当前页的指定标签<p>里面,替换原先的值。
比如打开index.php时,<p>标签显示为ddd,当按下aaa按钮时,<p>标签里的字被替换成aaa,当按下bbb按钮时,<p>标签里的字被替换成bbb,当按下ccc按钮时,<p>标签里的字被替换成ccc。
这个该怎样替换?<p>ddd<?php echo $_POST["name"]; ?></p>
<script language="javascript">
function sub(val)
{
document.getElementById("name").value =val;
}
</script>
<form action="index.php" method="post" target="_self">
<input name="name" id="name" type="hidden" value="" />
<input type="submit" value="aaa" style="border:none;" onclick="sub('aaa')">
<input type="submit" value="bbb" style="border:none;" onclick="sub('bbb')">
<input type="submit" value="ccc" style="border:none;" onclick="sub('ccc')">
</form><p><?php echo $_POST["name"]; ?></p>
比如打开index.php时,<p>标签里已经显示ddd了。