0
<form>
Select Project:*
<select name="project_id" id="project_id" >
<option value="0">Select Project</option>
<option value="1">a</option>
<option value="2">b</option>
<option value="3">c</option>
</select>

Select Week*:
<select name="week" id="week_id">
<option value="0">Select Week</option>
<option value="1">This Week</option>
<option value="2">Last Week</option>
<option value="3">2 Weeks back</option>
</select>

</form>



<script type="text/javascript" src="js/jquery-latest.js"></script>                    


<script>
  function showValues() {
    var str = $( "form" ).serialize();
    //$( "#mydiv" ).text( str );

  $.ajax({
      type :  'POST',
      url  :  'test.php',
      data :  str,
      dataType : "html",
      success: function(htmlResponse)
      {

      }
  });
  }

  $( "select" ).on( "change", showValues );
  showValues();
</script>




test.php

<?php
echo $_POST['project_id'];
echo $_POST['week'];
?>
2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by pzuurveen
0

works the result is in the htmlResponse var

<form>
Select Project:*
<select name="project_id" id="project_id" >
<option value="0">Select Project</option>
<option value="1">a</option>
<option value="2">b</option>
<option value="3">c</option>
</select>
Select Week*:
<select name="week" id="week_id">
<option value="0">Select Week</option>
<option value="1">This Week</option>
<option value="2">Last Week</option>
<option value="3">2 Weeks back</option>
</select>
</form>
<div>return:<span id="returnValue"></span></div>
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script>
function showValues() {
    var str = $( "form" ).serialize();
    //$( "#mydiv" ).text( str );
    $.ajax({
    type : 'POST',  
    url : 'test.php',
    data : str,
    dataType : "html",
    success: function(htmlResponse)
        {
        $("#returnValue").html(htmlResponse);
        }
    });
}

$( "select" ).on( "change", showValues );
showValues();
</script>

Edited by pzuurveen

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.