select onclick

Discussion in 'HTML' started by Dawn, Jan 6, 2004.

  1. Dawn

    Dawn Guest

    Hi,

    I use to have apache 1.3 installed on my computer. I did a clean
    install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
    decided to try apache2. Now I am having some problems. I know that php
    and mySQL are working fine. There were a few changed that I had to make
    to my code to get it to work, but for the most part, my code is working.

    This part of my code however is not working. I have the same code on
    another computer that is running apache1 and it is working find. Did I
    miss some in the setup?

    <form name="act_list" border=0>
    <table align="center">
    <tr><td>
    <select name=actors size=10
    onclick="parent.bottom.location.href='./actors.php?id=' +
    this.form.actors.options[this.form.actors.selectedIndex].value">

    <option value=331>Animal Characters
    <option value=319>Animation Characters
    <option value=98>Brandy
    <option value=366>Eve
    <option value=249>Madonna

    </select>
    </td></tr>
    </table>
    </form>

    When one of the select is click it is suppose to call the actors.php
    file (which it does) and send it the value (which it does not). I do
    not know why this does not work in apache2.

    Thanks
    Dawn
     
    Dawn, Jan 6, 2004
    #1
    1. Advertising

  2. In article <7bGKb.6856$>,
    says...
    > Hi,
    >
    > I use to have apache 1.3 installed on my computer. I did a clean
    > install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
    > decided to try apache2. Now I am having some problems. I know that php
    > and mySQL are working fine. There were a few changed that I had to make
    > to my code to get it to work, but for the most part, my code is working.
    >
    > <form name="act_list" border=0>
    > <table align="center">
    > <tr><td>
    > <select name=actors size=10
    > onclick="parent.bottom.location.href='./actors.php?id=' +
    > this.form.actors.options[this.form.actors.selectedIndex].value">
    > When one of the select is click it is suppose to call the actors.php
    > file (which it does) and send it the value (which it does not). I do
    > not know why this does not work in apache2.


    What does actors.php do? Does it use globals or does it use $_GET or
    $_POST? How is your form submitting the data - GET or POST? I think
    your code in actors.php is faulty, not Apache 2.

    --
    Hywel I do not eat quiche
    http://hyweljenkins.co.uk/
    http://hyweljenkins.co.uk/mfaq.php
     
    Hywel Jenkins, Jan 6, 2004
    #2
    1. Advertising

  3. Dawn

    Dawn Guest

    Hywel Jenkins wrote:
    > In article <7bGKb.6856$>,
    > says...
    >
    >>Hi,
    >>
    >>I use to have apache 1.3 installed on my computer. I did a clean
    >>install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
    >>decided to try apache2. Now I am having some problems. I know that php
    >>and mySQL are working fine. There were a few changed that I had to make
    >>to my code to get it to work, but for the most part, my code is working.
    >>
    >> <form name="act_list" border=0>
    >> <table align="center">
    >> <tr><td>
    >> <select name=actors size=10
    >> onclick="parent.bottom.location.href='./actors.php?id=' +
    >> this.form.actors.options[this.form.actors.selectedIndex].value">
    >>When one of the select is click it is suppose to call the actors.php
    >>file (which it does) and send it the value (which it does not). I do
    >>not know why this does not work in apache2.

    >
    >
    > What does actors.php do? Does it use globals or does it use $_GET or
    > $_POST? How is your form submitting the data - GET or POST? I think
    > your code in actors.php is faulty, not Apache 2.
    >

    This same code works in apache1. actors.php gets the id number by using
    $HTTP_POST_VARS['id'] and use that number to get information from a
    mysql DB and displays the information. I know the part where it gets
    the info and displays it works for tests that I have run. What I don't
    understand is how come I can not get the 'id' value.

    Because of the '?id=' from the code above, the form is submitted using
    the get method.
     
    Dawn, Jan 6, 2004
    #3
  4. In article <2OGKb.177$>,
    says...
    > Hywel Jenkins wrote:
    > > In article <7bGKb.6856$>,
    > > says...
    > >
    > >>Hi,
    > >>
    > >>I use to have apache 1.3 installed on my computer. I did a clean
    > >>install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
    > >>decided to try apache2. Now I am having some problems. I know that php
    > >>and mySQL are working fine. There were a few changed that I had to make
    > >>to my code to get it to work, but for the most part, my code is working.
    > >>
    > >> <form name="act_list" border=0>
    > >> <table align="center">
    > >> <tr><td>
    > >> <select name=actors size=10
    > >> onclick="parent.bottom.location.href='./actors.php?id=' +
    > >> this.form.actors.options[this.form.actors.selectedIndex].value">
    > >>When one of the select is click it is suppose to call the actors.php
    > >>file (which it does) and send it the value (which it does not). I do
    > >>not know why this does not work in apache2.

    > >
    > >
    > > What does actors.php do? Does it use globals or does it use $_GET or
    > > $_POST? How is your form submitting the data - GET or POST? I think
    > > your code in actors.php is faulty, not Apache 2.
    > >

    > This same code works in apache1. actors.php gets the id number by using
    > $HTTP_POST_VARS['id'] and use that number to get information from a
    > mysql DB and displays the information. I know the part where it gets
    > the info and displays it works for tests that I have run. What I don't
    > understand is how come I can not get the 'id' value.
    >
    > Because of the '?id=' from the code above, the form is submitted using
    > the get method.


    So you're using HTTP_POST_VARS to get the value but as submitting using
    GET? That's wrong.

    Check REGISTER_GLOBALS in php_info() - I suspect it's off. It's not a
    problem with Apache - it's your code or your PHP set-up. The POST array
    is nothing to do with Apache.

    --
    Hywel I do not eat quiche
    http://hyweljenkins.co.uk/
    http://hyweljenkins.co.uk/mfaq.php
     
    Hywel Jenkins, Jan 6, 2004
    #4
  5. On Tue, 06 Jan 2004 22:38:54 +0000, Dawn wrote:

    > This same code works in apache1.


    And an older version of PHP.

    > actors.php gets the id number by using $HTTP_POST_VARS['id']


    Which has since been replaced with $_POST (matching $_GET, and if you
    don't care which method, $_REQUEST). That's probably the bug.

    You might try

    <?php
    $HTTP_POST_VARS = $_POST;
    ?>

    if going through and replacing every instance of the former with the
    latter is too much effort. It's a bandaid at best, though, and you'd do
    far better to fix the code properly.

    --
    Some say the Wired doesn't have political borders like the real world,
    but there are far too many nonsense-spouting anarchists or idiots who
    think that pranks are a revolution.
     
    Owen Jacobson, Jan 6, 2004
    #5
  6. Dawn

    DU Guest

    Dawn wrote:

    > Hi,
    >
    > I use to have apache 1.3 installed on my computer. I did a clean
    > install and went from RedHat 9.0 to SUSE 9.0. In this clean installed I
    > decided to try apache2. Now I am having some problems. I know that php
    > and mySQL are working fine. There were a few changed that I had to make
    > to my code to get it to work, but for the most part, my code is working.
    >
    > This part of my code however is not working. I have the same code on
    > another computer that is running apache1 and it is working find. Did I
    > miss some in the setup?
    >
    > <form name="act_list" border=0>


    A form does not have a default border. So, border=0 is unneeded.

    > <table align="center">


    or <table style="margin:0px auto;"> if you want to make your page closer
    to web standards

    > <tr><td>
    > <select name=actors size=10


    For various reasons, it is always preferable and desirable to quote
    attribute values.

    Why attribute values should always be quoted in HTML
    http://www.cs.tut.fi/~jkorpela/qattr.html

    > onclick="parent.bottom.location.href='./actors.php?id=' +
    > this.form.actors.options[this.form.actors.selectedIndex].value">
    >


    The triggering event attribute is onchange. Also, I would code this in a
    more compact manner:

    onchange="parent.bottom.location.href='./actors.php?id=' +
    this.options[this.selectedIndex].value;"

    > <option value=331>Animal Characters


    Here, the value must be a string.

    <option value="331">Animal Characters</option>

    HTH

    DU

    > <option value=319>Animation Characters
    > <option value=98>Brandy
    > <option value=366>Eve
    > <option value=249>Madonna
    >
    > </select>
    > </td></tr>
    > </table>
    > </form>
    >
    > When one of the select is click it is suppose to call the actors.php
    > file (which it does) and send it the value (which it does not). I do
    > not know why this does not work in apache2.
    >
    > Thanks
    > Dawn
     
    DU, Jan 6, 2004
    #6
  7. Dawn

    Dawn Guest

    DU wrote:
    > Dawn wrote:
    >
    >> Hi,
    >>
    >> I use to have apache 1.3 installed on my computer. I did a clean
    >> install and went from RedHat 9.0 to SUSE 9.0. In this clean installed
    >> I decided to try apache2. Now I am having some problems. I know that
    >> php and mySQL are working fine. There were a few changed that I had
    >> to make to my code to get it to work, but for the most part, my code
    >> is working.
    >>
    >> This part of my code however is not working. I have the same code on
    >> another computer that is running apache1 and it is working find. Did
    >> I miss some in the setup?
    >>
    >> <form name="act_list" border=0>

    >
    >
    > A form does not have a default border. So, border=0 is unneeded.
    >
    >> <table align="center">

    >
    >
    > or <table style="margin:0px auto;"> if you want to make your page closer
    > to web standards
    >
    >> <tr><td>
    >> <select name=actors size=10

    >
    >
    > For various reasons, it is always preferable and desirable to quote
    > attribute values.
    >
    > Why attribute values should always be quoted in HTML
    > http://www.cs.tut.fi/~jkorpela/qattr.html
    >
    >> onclick="parent.bottom.location.href='./actors.php?id=' +
    >> this.form.actors.options[this.form.actors.selectedIndex].value">
    >>

    >
    > The triggering event attribute is onchange. Also, I would code this in a
    > more compact manner:
    >
    > onchange="parent.bottom.location.href='./actors.php?id=' +
    > this.options[this.selectedIndex].value;"
    >
    >> <option value=331>Animal Characters

    >
    >
    > Here, the value must be a string.
    >
    > <option value="331">Animal Characters</option>
    >
    > HTH
    >
    > DU
    >
    >> <option value=319>Animation Characters
    >> <option value=98>Brandy
    >> <option value=366>Eve
    >> <option value=249>Madonna
    >>
    >> </select>
    >> </td></tr>
    >> </table>
    >> </form>
    >>
    >> When one of the select is click it is suppose to call the actors.php
    >> file (which it does) and send it the value (which it does not). I do
    >> not know why this does not work in apache2.
    >>
    >> Thanks
    >> Dawn


    Thank you everyone for all of your help. It looks like I will need to
    get some updated HTML and PHP books. I will give these a try.
     
    Dawn, Jan 7, 2004
    #7
  8. Owen Jacobson wrote:
    > Which has since been replaced with $_POST (matching $_GET, and if you
    > don't care which method, $_REQUEST). That's probably the bug.
    >
    > You might try
    >
    > <?php
    > $HTTP_POST_VARS = $_POST;
    > ?>


    $HTTP_POST_VARS is still set in every current version of PHP, it's just
    deprecated. That can't be the problem.
     
    Leif K-Brooks, Jan 7, 2004
    #8
  9. Dawn wrote:

    > <form name="act_list" border=0>
    > <select name=actors size=10
    > onclick="parent.bottom.location.href='./actors.php?id=' +
    > this.form.actors.options[this.form.actors.selectedIndex].value">


    This is really suboptimal. Try:

    <form method="get" name="act_list" action="actors.php">
    <select name=id size=10
    onclick="parent.bottom.location.href='./actors.php?id=' +
    this.form.id.options[this.form.id.selectedIndex].value">

    And now your form will work for those 10%-15% of people without JavaScript.

    Getting back to your question...

    > I know that php [is] working fine.


    How? Because it worked under Apache 1.x? Because it works from the command
    line? If so, that's not enough.

    Check that you have the Apache2 version of mod_php installed. On Mandrake
    the package is called apache2-mod_php.

    Check that a basic test PHP file works:

    <?php
    header("Content-Type: text/plain");
    echo 1+1;
    ?>

    visit that page and you should just see a plain text file with the numeral
    2.

    If all that works, post back here with a test URL.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
     
    Toby A Inkster, Jan 7, 2004
    #9
  10. Leif K-Brooks <> wrote in message news:<QAKKb.92$>...
    > Owen Jacobson wrote:
    > > Which has since been replaced with $_POST (matching $_GET, and if you
    > > don't care which method, $_REQUEST). That's probably the bug.
    > >
    > > You might try
    > >
    > > <?php
    > > $HTTP_POST_VARS = $_POST;
    > > ?>

    >
    > $HTTP_POST_VARS is still set in every current version of PHP, it's just
    > deprecated. That can't be the problem.


    Is it populated if REGISTER_GLOBALS is off?

    --
    Hywel
     
    Hywel Jenkins, Jan 7, 2004
    #10
  11. Dawn

    Chris Morris Guest

    (Hywel Jenkins) writes:
    > Leif K-Brooks <> wrote
    > > $HTTP_POST_VARS is still set in every current version of PHP, it's just
    > > deprecated. That can't be the problem.


    Though $HTTP_POST_VARS isn't superglobal and $_POST is, which can
    cause problems.

    > Is it populated if REGISTER_GLOBALS is off?


    Yes, that just stops $foo being set to $_REQUEST['foo']

    --
    Chris
     
    Chris Morris, Jan 7, 2004
    #11
  12. In article <>,
    says...
    > (Hywel Jenkins) writes:
    > > Leif K-Brooks <> wrote
    > > > $HTTP_POST_VARS is still set in every current version of PHP, it's just
    > > > deprecated. That can't be the problem.

    >
    > Though $HTTP_POST_VARS isn't superglobal and $_POST is, which can
    > cause problems.
    >
    > > Is it populated if REGISTER_GLOBALS is off?

    >
    > Yes, that just stops $foo being set to $_REQUEST['foo']


    Of course - I was having a blonde moment.

    --
    Hywel I do not eat quiche
    http://hyweljenkins.co.uk/
    http://hyweljenkins.co.uk/mfaq.php
     
    Hywel Jenkins, Jan 7, 2004
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bob
    Replies:
    3
    Views:
    189
  2. Andrea
    Replies:
    0
    Views:
    294
    Andrea
    Jan 28, 2004
  3. palmiere
    Replies:
    1
    Views:
    413
    Erwin Moller
    Feb 9, 2004
  4. Replies:
    2
    Views:
    261
  5. Replies:
    4
    Views:
    187
Loading...

Share This Page