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
Problem with array max size.
Hi to everyone,
I've got a homework about filling a bidimensional array un spiral shape, I alre
Price in PR
Dear Experts,
Why we have to enter the price in the PR, and why there is no free goods indicato
Populate drop down list from table??
Lets say for arguments sake that i have a table which contains the numbers 1 to 10.
How can i get
Refining of search Criteria
Dear Friends
I need a help, I have a search page which of cars related, which has different s
PHP Programming error. Please help!
Hi there,
Am making a website for a friend and have encountered a problem that i need fixing
please help me in this update statment
hi every one
if I have table and this data in it
id name
10
help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted de
How to return to a previous page after running a PHP script
I'm having a bit of a melt down here because I think this should be really easy but can't work it ou
Content-Disposition: attachment; filename=... not working as i thought it should
taken the following code from the php.net site the script is not working.
what is not happeni
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :