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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

[!--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
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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
Link to comment
Share on other sites

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