user6065185 user6065185 - 4 months ago 14
Javascript Question

pass div value to another php is blank?

I have a div in form , I try to POST the value to another php using $_POS['calander'] in value.php , but it just return blank ,
how to get the div value from another php ?

<form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" action="value.php" method="post">
<div id="calander" class="pull-left" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc">
<i class="glyphicon glyphicon-calendar fa fa-calendar" id="reportrange_right"></i>

<span>&nbsp</span> <b class="caret"></b>
</div>
</form>


How do I post the div value to another php ?

Answer

You can use this it may help you ,

<form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" action="value.php" method="post">
<div id="calander" class="pull-left" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc">
<i class="glyphicon glyphicon-calendar fa fa-calendar" id="reportrange_right"></i>
 <span>&nbsp</span> <b class="caret"></b>
  </div>
  <input type="hidden" id="hiddeninput" name="hiddeninput">
  <input type="submit" id="subs" name="subs" value="Submit"/>
  </form>
  <script>
    $(function(){
      $('#subs').click(function () {
       var mysave = $('#calander').html();
        $('#hiddeninput').val(mysave);
       });
     });
   </script>

in your PHP Page use ,

 $_POST['hiddeninput']; 

to receive the value