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". 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.