Jump to content

onChange not working??


AdamPGT

Recommended Posts

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
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]
[!--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
[!--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.
[!--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.
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
Your form is submitting, but to its self! You will need something like this:
[code]<?php

if(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.
[!--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]<?php

if(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
  • 2 weeks later...

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.