Jump to content

php ajax - two drop down list with a submit button


orangge

Recommended Posts

i have created a form with 2 drop-down list and a submit button. I would like to know how to pass the selected values from the two drop down list to external javascript file and only will pass it after i clicked the submit button? Below is the example of my code:

 

<html>

 

<head>

<script type="text/javascript" src="selecttidmth.js"></script>

 

<title>Report</title>

</head>

 

<body>

<form action="getID.php" method="get">

Magazines:

<select name="tid" onchange="showTid(this.value)">

<option value="">---Select---</option>

<option value="1">Magazine A</option>

<option value="2">Magazine B</option>

</select>         

 

Month:

<select name="mth" onchange="showMonth(this.value)">

<option value="">---Select---</option>

<option value="Jan">January</option>

<option value="Feb">February</option>

<option value="Mar">March</option>

<option value="Apr">April</option>

<option value="May">May</option>

<option value="Jun">June</option>

<option value="Jul">July</option>

<option value="Aug">August</option>

<option value="Sept">September</option>

<option value="Oct">October</option>

<option value="Nov">November</option>

<option value="Dec">December</option>

</select>    

 

<input type="submit" name="submit" Value="Submit">

</form>

 

<div id="txtHint"></div>

</body>

</html>

 

//javascript code

 

var xmlhttp;

 

function showTid(str)

{

xmlhttp=GetXmlHttpObject();

if (xmlhttp==null)

  {

  alert ("Browser does not support HTTP Request");

  return;

  }

 

function showMonth(str2)

{

xmlhttp=GetXmlHttpObject();

if (xmlhttp==null)

  {

  alert ("Browser does not support HTTP Request");

  return;

  }

 

var url="getID.php";

url=url+"?q="+str+"?m="+str2;

url=url+"&sid="+Math.random();

xmlhttp.onreadystatechange=stateChanged;

xmlhttp.open("GET",url,true);

xmlhttp.send(null);

}

 

Hope someone here can help me out. Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.