当复选框处于选中状态时,我正在尝试显示文本框。当任何复选框被选中时,我有3个复选框,以显示特定复选框的文本框。然后输入checkbox的值和textbox的值,以通过php发送。如何在php中显示选中的复选框和文本框值。我发现了php中的困难,如何在php中显示选中的复选框和特定的文本框值。
以下是代码
<form action="" method="POST">
<div id="opwp_woo_tickets">
<input type="checkbox" class="maxtickets_enable_cb" name="opwp_wootickets[tickets][0][enable]" value="cxfdvbbxbccv">check1
<div class="max_tickets">
<input type="text" name="opwp_wootickets[tickets][0][maxtickets]">
</div>
<input type="checkbox" class="maxtickets_enable_cb" name="opwp_wootickets[tickets][1][enable]" value="xc bvcvbcvbnb">check2
<div class="max_tickets">
<input type="text" name="opwp_wootickets[tickets][1][maxtickets]">
</div>
<input type="checkbox" class="maxtickets_enable_cb" name="opwp_wootickets[tickets][2][enable]"value="cxrdyrty rty tr">check3
<div class="max_tickets">
<input type="text" name="opwp_wootickets[tickets][2][maxtickets]">
</div>
</div>
<input type="submit" name="submit" value="submit">
</form>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>index.js
jQuery(document).ready(function($) {
// STOCK OPTIONS
$('input.maxtickets_enable_cb').change(function(){
if ($(this).is(':checked'))
$(this).next('div.max_tickets').show();
else
$(this).next('div.max_tickets').hide();
}).change();
});PHP
<?php
if(isset($_POST["submit"]))
{
$checkbox1=$_POST['opwp_wootickets'];
$chk="";
foreach($checkbox1 as $chk1)
{
$chk .= $chk1.",";
}
echo "$chk";
}发布于 2018-08-16 12:25:24
这里isAgeSelected是checkbox,txtage是inputbox或txt
if($('#isAgeSelected').checked) {
$("#txtAge").show();
} else {
$("#txtAge").hide();
}https://stackoverflow.com/questions/51869514
复制相似问题