我试图在选中复选框时显示一个文本框。当任何一个复选框被选中时,我都有3个复选框,以显示该特定选中复选框的文本框。然后,复选框的值和输入的文本框值将通过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";
}
答案 0 :(得分:0)
此处isAgeSelected为7
1 2 3 3 2 4 3
,txtage为1 2 3 4
2 3
3
或checkbox
inputbox