0

I am using a dropdown box with 6 options. On change I want ajax to return part of an HTML/PHP page that corresponds to one of the 6 questions. I was trying to put and if statement on the return page to determine the part that I wanted but I didnt work. I rather not create 6 HTML/PHP files for each of the options. Here is part of the CODE

CREATE A:		
		<select name="mychoice" onchange="onchange_getform(this.value)">
			<option>----Select----</option>
			<option value="1">Application</option>
			<option value="2">Contact</option>
			<option value="3">Program</option>
			<option value="4">Project</option>
			<option value="5">Category</option>
			<option value="6">Question</option> 
		</select>

this part above selects the type i want to create-

function onchange_getform(str)
		
			{
			alert(str);
			if (str=="")
			{
			document.getElementById("mychoice").innerHTML="";
			return;
			} 
			if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
			}
			else
			{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function()
			{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("create_form").innerHTML=xmlhttp.responseText;
				}
			}
			xmlhttp.open("GET","create_entity.php?q="+str,true);
			xmlhttp.send();

the create_entity has the form layouts for each of the 6 entities. is it possible to distinguish on the page being request ("create_entity") or do i have to make 6 separate ajax call to 6 separate php pages.
if u guys could point me in the right direction that would be great

-jaycastr

3
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by jaycastr
0

i solved it like this

on the requested page

switch ($_GET['q'])
{
    case 1;
    echo"form stuff";
    break;
    case 2
echo"form stuff";
break;
default:
echo""

}

thanks to though

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.