using Select tag to populate dynamic list - but how to make those list items links?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jody Bowers
    New Member
    • Oct 2011
    • 2

    #1

    using Select tag to populate dynamic list - but how to make those list items links?

    I'm using the select tag to populate a dynamic list of work categories from our database. I accomplished this just fine but how do I now make those list items link to the corresponding pages?

    ie. Click on Accounting and populate a page with only those members in the accounting field.

    Code:
    <div id="Categories"><select name="list" size="105">
        <?php
    do {  
    ?>
        <option value="<?php echo $row_RS_Categories['ID']?>"<?php if (!(strcmp($row_RS_Categories['ID'], urlencode($row_RS_Categories['Categories'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_RS_Categories['Categories']?></option>
        <?php
    } while ($row_RS_Categories = mysql_fetch_assoc($RS_Categories));
      $rows = mysql_num_rows($RS_Categories);
      if($rows > 0) {
          mysql_data_seek($RS_Categories, 0);
    	  $row_RS_Categories = mysql_fetch_assoc($RS_Categories);
      }
    ?>
      </select>
      </div>
    Last edited by Dormilich; Oct 12 '11, 05:49 AM. Reason: please use [CODE] [/CODE] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    not at all (at least not with HTML only). for that to work you have two options
    - submit the form and within PHP redirect to the appropriate page
    - use JavaScript to change the action attribute of the form so that the submit takes you to the desired destination

    Comment

    • Jody Bowers
      New Member
      • Oct 2011
      • 2

      #3
      it's not in a form, just a div/select box that pulls up the list of categories. I want to format it so when you click on one of the categories it takes you to a page populated with only the members with that field selected.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        it's not in a form
        if it’s a <select>, it has to be inside a <form>, otherwise your HTML is invalid.

        if you insist on not using forms, try a CSS Dropdown Menu (e.g. the Suckerfish Dropdown)

        Comment

        • freefony
          New Member
          • Nov 2008
          • 59

          #5
          i suggest AJAX i ve used it several times for stuffs like that gives u double advantage loads faster and works for u

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            I doubt that for this case.

            Comment

            Working...