选中复选框时显示文本框,并以 php 格式发布这两个值



我正在尝试在选中复选框时显示文本框。当选中任何复选框时,我有 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>

索引.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";
}

Here isAgeSelected 是checkboxtxtage 是inputboxtxt

if($('#isAgeSelected').checked) {
$("#txtAge").show();
} else {
$("#txtAge").hide();
}

最新更新