Just_Johnny Posted March 24, 2009 Share Posted March 24, 2009 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". Quote Link to comment Share on other sites More sharing options...
Just_Johnny Posted March 24, 2009 Author Share Posted March 24, 2009 Can somebody please just point me in the right direction? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.