0

I am trying to display a textbox when a checkbox is checked. I have 3 checkbox when any of the checkbox is checked it as to display a textbox for that particular checked checkbox. And then the value of checkbox and the textbox value which is entered as to be sent through php. How can I display the checked checkbox and textbox value in php. I am finding the difficulty in php how to display the checked checkbox and particular textbox value in php

Here is the code

<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";
}
user3168637
  • 111
  • 4
  • 13
  • Try [turning on error reporting](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display). Your script should be producing an "array to string conversion" error. Hopefully that's enough information to point you in the right direction. – Mike Aug 16 '18 at 04:20

1 Answers1

0

Here isAgeSelected is checkbox and txtage is inputbox or txt

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