gpt4 book ai didi

javascript - 如何在不同 session 中绑定(bind)多个复选框

转载 作者:行者123 更新时间:2023-11-30 20:55:31 25 4
gpt4 key购买 nike

我有一些带有复选框的数据。现在我想,当任何人点击复选框时,所有选中的数据都应该在 session 中绑定(bind),并且应该进入下一页。再一次,如果有人点击复选框,那么新点击的数据应该在 session 中。但旧数据不应删除。我试过但没有用,任何事情。请帮忙。

                            <form  name="reservation_form" class="reservation-form mb-0" action="second.php" method="post" novalidate>

<div class="col-xs-12 col-sm-6 col-md-4">
<div class="form-group mb-15">
<input name="name1" class="form-control required " type="text" placeholder="Enter Name" aria-required="true">
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="form-group mb-15">
<input name="email1" class="form-control required " type="email" placeholder="Enter Email" aria-required="true">
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="form-group mb-15">
<input name="phone1" class="form-control required " type="text" placeholder="Enter Phone" aria-required="true">
</div>
</div>
<?php
$query1=mysql_query("select * from lab_location_package_rel where city_id='$selectcity1' AND area_id='$selectarea1' AND lab_id='$selectlab1'") or die (mysql_error());
while($value = mysql_fetch_array($query1)) {
$mrp=$value['mrp'];
$opp=$value['offer_price_perc'];
$package_id=$value['package_id'];

$per=$mrp*$opp/100;
$total=$mrp-$per;

$query2=mysql_query("select * from package_master where id='$package_id'") or die (mysql_error());
$value2 = mysql_fetch_array($query2);
?>
<li class="list-group-item">
<div class="checkbox">
<input type="checkbox" id="checkbox" name="name[]" />
<label for="checkbox">
<b>Package Name:</b> <?php echo $value2['package_title']; ?> <br>
<b>MRP:</b> <strike><?php echo $value['mrp']; ?> </strike><br>
<b>Offer Price:</b> <?php echo $total; ?>
</label>
</div>
<div class="pull-right action-buttons">
<a href="#" class="btn btn-info">View Details</a>
</div>
</li>
<?php } ?>

</ul>
</div>
<input type="button" class="pull-right btn btn-warning" value="Submit">
</form>

在给定的代码中,当任何人填写所有字段并单击复选框时-

<input type="checkbox" id="checkbox" name="name[]" />
<label for="checkbox">
<b>Package Name:</b> <?php echo $value2['package_title']; ?> <br>
<b>MRP:</b> <strike><?php echo $value['mrp']; ?> </strike><br>
<b>Offer Price:</b> <?php echo $total; ?>
</label>

然后所有填写的字段和包裹名称、MRP、报价(将为每个复选框选择这些名称)应在 session 中绑定(bind)。

最佳答案

像这样传递并在提交表单时获取值

input type="checkbox"id="checkbox"name="names[]"value="$value2['package_title']">

input type="checkbox"id="checkbox"name="names[]"value="$value['mrp']">

input type="checkbox"id="checkbox"name="names[]"value="$total"/>

$name=$_POST['名字'];$answer = 内爆($name, ",");

然后将名称值分配给 session 。

$_SEESION['name']=$answer;

关于javascript - 如何在不同 session 中绑定(bind)多个复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47708619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com