2 Replies Latest reply: Jun 13, 2006 3:35 PM by rezun8 RSS

    PHP drop Down menu

    rezun8 Community Member
      hi Everyone, my turn for help-

      I have inherited a web project from another person and have an issue regarding a drop down list that is tied in some way to another drop down list, the 2 are side by side as seen here > http://www.srf.org/preview/ < at the top you will see a SEARCH field then a Drop Down where the user can select ALL , INTERNATIONAL, or DOMESTIC. Next to that is a drop down list with YEAR as a choice.

      the two drop down lists are tied together so that (which I don't want) if you pick a YEAR then it reverts the other DD to INTERNATIONAL
      I need it so that both fields run independent of each other.

      here is the PHP for the table it lies within:

      <td width="679" bgcolor="#EEEEEE"><input name="cerca" type="text" class="dataHpNews" size="16">
      in
      <select name="categoria" class="dataHpNews" id="categoria" onChange="MM_changeProp('mytype1','','selectedIndex','0','SELECT')">
      <option <?php if ($categoria=="all") echo("selected"); ?> value="all" selected>All</option>
      <option <?php if ($categoria=="Domestic") echo("selected"); ?> value="Domestic">Domestic Grants</option>
      <option <?php if ($categoria=="International") echo("selected"); ?> value="International">International Grants</option>
      </select>
      and in year
      <select name="mytype1" id="mytype1" onChange="MM_changeProp('categoria','','selectedIndex','2','SELECT')">
      <option value="" <?php if (!(strcmp("", $row_programarea['nome']))) {echo "selected=\"selected\"";} ?>>Select...</option>
      <?php
      do {
      ?>
      <option value="<?php echo $row_programarea['nome']?>"<?php if ($row_programarea['nome']==$mytype1) {echo "selected=\"selected\"";} ?>><?php echo ($row_programarea['family'].", ".$row_programarea['nome']); ?></option>
      <?php
      } while ($row_programarea = mysql_fetch_assoc($programarea));
      $rows = mysql_num_rows($programarea);
      if($rows > 0) {
      mysql_data_seek($programarea, 0);
      $row_programarea = mysql_fetch_assoc($programarea);
      }
      ?>
      </select>
      <input name="Submit" type="submit" class="dataHpNews" value="Go"></td>


      can someone help me clear this issue?
      I'm a Flash guy and have rudimentary PHP skills

      Thanks a Billion

      R2
        • 1. Re: PHP drop Down menu
          Newsgroup_User Community Member
          rezun8 wrote:
          > the two drop down lists are tied together so that (which I don't want) if you
          > pick a YEAR then it reverts the other DD to INTERNATIONAL
          > I need it so that both fields run independent of each other.

          > I'm a Flash guy and have rudimentary PHP skills

          The PHP has nothing to do with the change in the drop-down menus. It's
          controlled entirely by the JavaScript onChange event.

          Remove the following code from both select elements:

          onChange="MM_changeProp('mytype1','','selectedIndex','0','SELECT')"

          and

          onChange="MM_changeProp('categoria','','selectedIndex','2','SELECT')"

          The PHP code has an effect only when the page is reloaded, because PHP
          is a server-side language. The connection between the two drop-downs is
          controlled on the client-side by JavaScript.

          --
          David Powers
          Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
          Author, "Foundation PHP 5 for Flash" (friends of ED)
          http://foundationphp.com/
          • 2. Re: PHP drop Down menu
            rezun8 Community Member
            Thanks David,
            unbelivably that makes complete sense to me! I will give it a try

            Regards

            Russ