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
timezone change with date()
so i put all my times for posts in my made from scratch forum(not phpbb3 or sm)
in my mysql db u
reorder sql query
ok so i have this very simple code:
Code: $query = "SELECT search_keywords, COUNT(search_key
User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the mo
Problems with returning true or false in eval()'d code
Hi guys,
Would appreciate some help with a problem when running eval() on a function that sho
Mysql query, two times?
Hello to all,
I'm new to php coding and i like it alot. I need help with some noob stuff.
please, need help coding this voting for your favorite car polling system.
hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, upda
Remove directories not empty
hi,
i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder.<
Empty text file when there is over XXXX lines of text.
define("RANDOM_FILE","/public_html/random.txt");
$randomEntry = "
Help please - How to validate from 2 possible answers
Hi
I hope somebody can help me with what will probably be really simple, I'm pulling my hair
Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system
Say I go to h