单击按钮时复选框自动选中 [英] Checkbox auto checked when click on button

查看:296
本文介绍了单击按钮时复选框自动选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个php页面,分别是 home.php enquiry.php .

在home.php上,有5个按钮(查询按钮),当用户单击按钮时,它将转到enquiry.php页面(获得5个不同的复选框值),并将基于按钮id在home.php页面中选中复选框.

您能告诉我如何实现吗?
感谢任何解决方案.

I got 2 php pages which are home.php and enquiry.php.

On home.php got 5 buttons (Enquiry Buttons) that when user clicks, it will go to enquiry.php page (got 5 different checkbox values) and will checked the checkbox based on button id click in home.php page.

Can you please let me know how this can be achieved ?
Any solution is appreciated.

推荐答案

home.php
home.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>home.php</title>
</head>
<body>
<form action="enquiry.php" method="post">
<button type="submit" name="button1">button id 1</button>
<button type="submit" name="button2">button id 2</button>
</form>
</body>
</html>


enquiry.php


enquiry.php

<html>
<head>
<meta charset="utf-8">
<title>enquiry.php</title>
</meta></head>
<body>
<input type="checkbox" value="Checkbox1"

    <?php if(isset(


_POST ['button1']))) echo 选中"; ? > >您已单击按钮1 < br > < 输入 =" 复选框" <​​/span> Checkbox2" <?php
_POST['button1'])) echo 'checked'; ?> >You have clicked button 1<br> <input type="checkbox" value="Checkbox2" <?php if(isset(


_POST ['button2']))) echo 选中"; ? > >您已经单击了按钮2 < /body > < /html >
_POST['button2'])) echo 'checked'; ?> >You have clicked button 2 </body> </html>


这篇关于单击按钮时复选框自动选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆