php combo box code nt working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    php combo box code nt working

    my code is not working........ .
    [PHP]<?php

    echo"<select name=$sarea >";
    $option = "<option value=\"Please select a Subject Area\">Please select a Subject Area</option> \n";
    for ($i = 0; $i < count($subjarea ); $i++) {
    $option .= "<option ";
    $option .= "value=\"$subja rea[$i]\">$subjarea[$i]</option> \n";
    }
    echo $option;
    ?>

    </select>

    <a href="webmain.p hp?sarea=<?php echo $sarea; ?>">show</a>;
    <br>[/PHP]
    webmain.php
    [PHP]$sarea=$_GET['sarea'];
    echo $sarea;[/PHP]
    i want to print selected subject area on webmain.php
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    first, you're missing quotation marks in line 3
    second, what is $sarea? I can see it nowhere defined. If you don't get any output check the variable content with var_dump().

    regards

    Comment

    • kkshansid
      New Member
      • Oct 2008
      • 232

      #3
      combo box is showing data but selected data doesnot go to other page
      $sarea is the name given to combo box

      Comment

      • kkshansid
        New Member
        • Oct 2008
        • 232

        #4
        not passing variable to other page

        [PHP]my code is not working........ .[/PHP]
        [PHP]<?php

        echo"<select name=$sarea >";
        $option = "<option value=\"Please select a Subject Area\">Please select a Subject Area</option> \n";
        for ($i = 0; $i < count($subjarea ); $i++) {
        $option .= "<option ";
        $option .= "value=\"$subja rea[$i]\">$subjarea[$i]</option> \n";
        }
        echo $option;
        ?>

        </select>

        <a href="webmain.p hp?sarea=<?php echo $sarea; ?>">show</a>;
        <br> [/PHP]

        webmain.php
        [PHP]$sarea=$_GET['sarea'];
        echo $sarea; [/PHP]



        cobbo box has data.combo box is working but
        i want to print selected subject area on webmain.php
        which is not working
        i think there is error in combo box name but i am not sure what should be there plz help

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          Originally posted by kkshansid
          combo box is showing data but selected data doesnot go to other page
          unless you post the data (via submit) your selected data will go nowhere. once your script has finished delivering the html page you can't do anything with php (including capturing user actions (like select something)) up to the next page load. so without a form you'll just pass the name, not more, not less.

          regards

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            please do not double post! see posting guidelines

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              kkshansid, you have been warned a few times previously about your lack of following posting guidelines. It is in your best interest to follow them as you are teetering towards receiving a temporary ban.

              Posting Guidelines - read them.

              Comment

              Working...