Results 1 to 2 of 2

Thread: PHP drop down assistance needed.

  1. #1
    Join Date
    May 2010
    Posts
    5

    PHP drop down assistance needed.

    I am trying to make a database of college bars, organized by school. I created a form for bars to add themselves to the database that can be found at http://sofnthirsty.com/kevin/bar.php?act=add Ideally- for those of you who looked at the form - I would like to have the Nearby School/University drop down display a list of Schools in a given state. For example: When someone selects NJ in the State dropdown above- the Nearby School/University menu would show Rutgers, Stockton College, Kean, Farleigh ****inson, Seton Hall, Princeton, Montclair, Rowan, etc etc. so I need to change the code below accordingly. Any help would be appreciated, I hope I gave you guys enough information to be able to provide assistance.. Here is the code so far:

    PHP Code:
      <tr>
            <td class="fieldheading">State</td>
            <td><select class="ddown" name="bstate" id="bstate" style="width:231px">
            <?php 
        
    foreach( $states as $key=>$value)
        {
    ?>
            <option <?php if($value=="AL"){echo 'selected="selected"';} ?> value="<?php echo $value;?>"><?php echo $key;?></option>
            
            <?php ?>
        </select>
        </td>
          </tr>

          <tr>
            <td class="fieldheading">NearBy School/University</td>
             <td>
             <?php 
                  $qry_schools 
    "SELECT * FROM ".$tblprefix."schools"
                
    $rs_schools  $db->Execute($qry_schools);
               
    ?>        
                <select class="ddown" name="bschool" id="bschool" style="width:231px">
                     <?php while(!$rs_schools->EOF){?>
                        <option value="<?php echo $rs_schools->fields['id'];?>">
                            <?php echo $rs_schools->fields['name'];?>
                        </option>
                            <?php $rs_schools->MoveNext();
                              } 
                            
    ?>
                </select>                
            </td>
          </tr>
    Last edited by ksharpesays; 13 Jun 2010 at 12:12 PM. Reason: elaborating on code.

  2. #2
    Join Date
    Dec 2009
    Location
    Carrollton, GA - USA
    Posts
    67
    You are going to have to do this with javascript. I don't have any codes that I have written that do this but it can be done. search google for something like "javascript form Change Dropdown menu by other menu" Also found this link with a working example.

    http://www.trans4mind.com/personal_d...tripleMenu.htm

    Good luck.

Similar Threads

  1. PHP pro needed, Im stuck.
    By king10 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 12 Feb 2010, 05:49 AM
  2. PHP and HTML/CSS developer needed
    By alwinred in forum Job Offers
    Replies: 0
    Last Post: 06 Aug 2009, 05:09 PM
  3. Hide/show a text box based on drop down list in php
    By TechnoAtif in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 11 Jan 2008, 01:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •