I have created a simple select php script that return data from my db. I was was wondering how i would go about creating a Jquery function that passes a variable to the php page. Am i right in thinking this will not require the html page to be refreshed?
The function is called when the drop down menu choice changes. I wish to pass the value of the drop down menu to PopulateBoxes.php.
HTML
<head>
<link href="../UserTemplate.css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Tours</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"> </script>
<script type="text/javascript">
function popBox(str)
{
//Jquery function to pass variable to PopulateBoxes.php
}
</script>
</head>
<body>
<select name="lst_MonthDrop" style="background-color:#FF9933; color:#FFF; border:none; margin-top:10px; margin-left:10px;" onchange="popBox(this.value);">
<option>Please Select</option>
<?php
include 'populatedrodown.php';
foreach ( $results as $option ) : ?>
<option value="<?php echo $option->Date; ?>"><?php echo $option->Date; ?></option>
<?php endforeach; ?>
</select>
</body>
</html>
PHP
<?php
$passed = $_POST['passedvariable'];
$mysql_db_hostname = "localhost";
$mysql_db_user = "root";
$mysql_db_password = "pwd";
$mysql_db_database = "db";
$con = mysql_connect($mysql_db_hostname, $mysql_db_user, $mysql_db_password) or die("Could not connect database");
mysql_select_db($mysql_db_database, $con) or die("Could not select database");
$sql="SELECT * FROM Tour WHERE Date = '".$passed."'";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result))
{
$Duration = $row['Duration'] ;
$Vessel = $row['Vessel_Name'] ;
$Location = $row['Location'] ;
$Available = $row['Available'];
$Price = $row['Price'];
echo $Price;
}
mysqli_close($con);
?>
If any could help i'd really appreciate it, I have been struggling to come to terms with jquery and especially this function for hour. Thanks in advance.