Jump to content

prototype.js - Returns only one of my forms data


Just_Johnny

Recommended Posts

I think I'm finally starting to get this.

 

<html>
<title>php-learn-it.com - php ajax form submit</title>
<head>		
	<script type="text/javascript" src="prototype.js"></script>
	<script>

		function sendRequest() {
			new Ajax.Request("test2.php", 
				{ 
				method: 'post', 
				postBody: 'make='+ $F('id1'),
				onComplete: showResponse 
		  	});
	  }


		function showResponse(req){
			$('show').innerHTML= req.responseText;
		}


	</script>
</head>

<body>


	<form id="test" onsubmit="return false;">

		<select name="make" id="id1">;
		<? for($x=0;$x<count($makeArray);$x++){
		 	 echo "<option value=\"".$makeArray[$x]."\">".$makeArray[$x]."</option>";
			 }
		?>			
		</select> 

		<select name="year" id="id2">;

		 	<option value="1998">1998</option>
			<option value="1999">1999</option>

		</select> 


		<input type="submit" value="submit" onClick="sendRequest()">
	</form>

	<div id="show"></div>
	<br/><br/>

</body>

</html>

 

I return print_r($_POST) and it looks like this.

 

Array

(

    [make] => Acura

)

 

My first drop down form returns exactly what I want, but I'm having trouble with getting the second drop down.  I reverted the js code back to working with just the first drop down "id1". 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.