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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

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> &nbsp; &nbsp;

<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 Like 23 Dislike
Previous forums Next forums
Other forums

How to restrict the display of report variants
Hello All,

I want t know how to restrict the display of report variants.
I mean, whe

Stumped by Third Day of Month problem
I am trying to build an algorithm that will essentially do this:
Code: [Select]$this_month = Oct

Php WordPress help
I am writing the following code for making a plugin

<?php
header("Content-Type

TinyMCE / Ajax Postback Problem
Hiya all,

I have a page which loads the TinyMCE editor. On the postback I obviously want to f

php code to accept and delete incoming data
Using following HTML Code please show me how to write PHP code to accept and delete the incoming dat

question about n
I was looking at some of the things you could do with php and one of the things I have tried is n.<

Form File Upload
I've read through tons of resources and tutorials and as far as I can tell, my code is accurate, but

How to get the previous months last date....
Here's my wittle problem. I suck at working with dates.

So today is 10/20/2009, i need to fig

PHP error (line 38) my website
Hello everyone, I'm new on this
and I got a web site thats got a error not showing the photos on<

help with calculations on a flat text file
hello,
I have this code below that is attached to a flat file like this:
Email:LastName:FirstN

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash