在php中,多个单选按钮可以设置一样的name,那么多个submit按钮可以吗?
3个回答
展开全部
可以的,看代码吧:
name设置一致,根据value属性获得点击的是哪一个
<?php
header("Content-type: text/html; charset=utf-8");
if(isset($_POST['submit'])){
var_dump($_POST['submit']);
}
?>
<h1><?php echo $result;?></h1>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<p><input type="submit" name="submit" value="submit1"></p>
<p><input type="submit" name="submit" value="submit2"></p>
<p><input type="submit" name="submit" value="submit3"></p>
</form>
name设置一致,根据value属性获得点击的是哪一个
<?php
header("Content-type: text/html; charset=utf-8");
if(isset($_POST['submit'])){
var_dump($_POST['submit']);
}
?>
<h1><?php echo $result;?></h1>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<p><input type="submit" name="submit" value="submit1"></p>
<p><input type="submit" name="submit" value="submit2"></p>
<p><input type="submit" name="submit" value="submit3"></p>
</form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询