php ajax - two drop down list with a submit button
Posted on
16th Feb 2014 07:03 pm by
admin
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.
No comments posted yet
Your Answer:
Login to answer
164
23
Other forums
How to write on database when a link is clicked?
Hi,
I have a list of products in a gridview. When the link is clicked currently it takes to an ext
Adding Different Numbers From MySQL
Basically I have a mysql database with a couple prices as the following:
9.99
9.99
9.99
php unable to sent email
Hi, guys, I try to send a email through php but unfortunately the mail unable to sent. Here is my co
Need help urgant
why down my code ony return one item instead of all the items selected.
$arr = array($date,$
Conditions of info record - Error
When i created GR (901) and PO create automatic my PBXX is obtain the net price of info record but
Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba
Time-based image rotation script
I'm trying to write a PHP script that rotates an image based on what time of day it is. I want the
Help with captcha script needed
Hello,
I am working on a script where reCAPTCHA or a similar form of CAPTCHA will be used, f
Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..
Need Successful Return
Hello I am currently working a form here, and I have everything figured out except when I click the