AdamPGT Posted April 7, 2006 Share Posted April 7, 2006 The form fields are being generated via JS, but for some reason when I select the third option, nothing happens.Here's the code:[code]<form name="form" method="POST" action="<?=$_SERVER['PHP_SELF']?>"><table align="center"> <tr> <td><select name="make" style="width:160px;"></select></td> </tr> <tr> <td><select name="model" style="width:160px;"></select></td> </tr> <tr> <td><select name="year" style="width:160px;" onChange="this.form.submit();"></select></td> </tr> <tr> <td> </td> </tr></table></form>[/code]Thanks for any help!Adam Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 7, 2006 Share Posted April 7, 2006 Your code wont work as there is nothing to select! You'll want to use the <option></option> tag so the user can select an option from the pull down menu. Heres an example:[code]<form name="form" method="POST" action="<?=$_SERVER['PHP_SELF']?>"><select name="year" style="width:160px;" onChange="this.form.submit();"> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option></select></form>[/code] Quote Link to comment Share on other sites More sharing options...
AdamPGT Posted April 7, 2006 Author Share Posted April 7, 2006 [!--quoteo(post=362620:date=Apr 7 2006, 01:05 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 7 2006, 01:05 PM) [snapback]362620[/snapback][/div][div class=\'quotemain\'][!--quotec--]Your code wont work as there is nothing to select! You'll want to use the <option></option> tag so the user can select an option from the pull down menu. Heres an example:[code]<form name="form" method="POST" action="<?=$_SERVER['PHP_SELF']?>"><select name="year" style="width:160px;" onChange="this.form.submit();"> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option></select></form>[/code][/quote]The Options are being generated dynamically using PHP/JS.....even after looking at the page source when everything has been created no <option> tags show up.--Adam Quote Link to comment Share on other sites More sharing options...
slipperyfish Posted April 9, 2006 Share Posted April 9, 2006 do you have a link? - and in tht case the problem does not lie with ur onChange function. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 9, 2006 Share Posted April 9, 2006 [!--quoteo(post=362628:date=Apr 7 2006, 08:17 PM:name=AdamPGT)--][div class=\'quotetop\']QUOTE(AdamPGT @ Apr 7 2006, 08:17 PM) [snapback]362628[/snapback][/div][div class=\'quotemain\'][!--quotec--]The Options are being generated dynamically using PHP/JS.....even after looking at the page source when everything has been created no <option> tags show up.--Adam[/quote]In that case then there is a problem with your PHP or Javascript that creates the <option></option> tags as they are not being generated!Could you provide a link for the page has a problem so we can see how your Javascript. Also could you tell us how you are generating your <option> tags with pHP/Javascript. Quote Link to comment Share on other sites More sharing options...
Vorotaev Posted April 9, 2006 Share Posted April 9, 2006 [!--quoteo(post=362628:date=Apr 7 2006, 03:47 PM:name=AdamPGT)--][div class=\'quotetop\']QUOTE(AdamPGT @ Apr 7 2006, 03:47 PM) [snapback]362628[/snapback][/div][div class=\'quotemain\'][!--quotec--]The Options are being generated dynamically using PHP/JS.....even after looking at the page source when everything has been created no <option> tags show up.--Adam[/quote]When using Javascript to dynamically produce code, the changes will not be reflected in the source HTML. The source only shows the page as it was when it was first compiled. Just so you know. Quote Link to comment Share on other sites More sharing options...
AdamPGT Posted April 9, 2006 Author Share Posted April 9, 2006 HOw would you suggest I submit the form with the change of the third select? Here's a link....I have to edit my .htaccess file real quick:[a href=\"http://www.gforceauto.com/chain.php\" target=\"_blank\"]http://www.gforceauto.com/chain.php[/a]--Adam Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 10, 2006 Share Posted April 10, 2006 Your form is submitting, but to its self! You will need something like this:[code]<?phpif(isset($_POST['year'])){ echo "Your have chosen: " . $_POST['make'] . " as the make, " . $_POST['model'] . " as the model, and " . $_POST['year'] . "as the year!";}?>[/code]If you wish to show what has been submitted. Quote Link to comment Share on other sites More sharing options...
AdamPGT Posted April 10, 2006 Author Share Posted April 10, 2006 [!--quoteo(post=363255:date=Apr 10 2006, 04:42 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 10 2006, 04:42 AM) [snapback]363255[/snapback][/div][div class=\'quotemain\'][!--quotec--]Your form is submitting, but to its self! You will need something like this:[code]<?phpif(isset($_POST['year'])){ echo "Your have chosen: " . $_POST['make'] . " as the make, " . $_POST['model'] . " as the model, and " . $_POST['year'] . "as the year!";}?>[/code]If you wish to show what has been submitted.[/quote]THis is already in place:[code]if (isset($_POST['year'])){ header("Location: index.php?cPath=" . $_POST['make'] . "_" . $_POST['model'] . "_" . $_POST['year']); }[/code]Which would send the page to index.php?cPath=xx_xx_xx, however, the form itself is simply not submitting, that's what I need help with. I need to submit this form without using a Submit button, even though using a submit button does work.--Adam Quote Link to comment Share on other sites More sharing options...
AdamPGT Posted April 18, 2006 Author Share Posted April 18, 2006 Anyone have any ideas? I noticed the onClick action works, but it's a bit pre-mature and doesn't grab the third variable.--Adam 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.