Advanced Search

Results 1 to 2 of 2

Thread: populating one drop down with another

  1. #1
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default populating one drop down with another

    I want to populate one drop down with another.
    The two drop downs are Projects, and Tasks. If a user select a project, the tasks should populate according to the project selected.
    I can populate task list on the basis of project id, but I don't know how to refresh that list every time a different project is selected. Any help? direction?

    my project drop down:
    Code:
    <select name="pid">
    								[INDENT][INDENT][INDENT]<?
    									while ($row=mysql_fetch_array($resultProject)) {
    	
    										$pid=$row["pid"];
    										$value=$row["project_name"];
    								?>
    									
    									<option value="<?=$pid?>" ><?=$value?></option> 
    								<? 	} 
    								?>
    								</select>
    and my tasks drop down:
    Code:
    <select name="tid">
    								<?
    									$sqlTask="SELECT * from tasks where pid=$pid ;";
    									$resultTask=mysql_query($sqlTask);
    									$optionsTask="";
    																	
    									while ($row=mysql_fetch_array($resultTask)) {
    	
    										$pid=$row["tid"];
    										$value=$row["task_name"];
    									
    								?>
    									<option value="<?=$tid?>"><?=$value?></option> 
    								<? 	} 
    								?>
    								</select>

  2. #2
    Join Date
    Sep 2008
    Posts
    115
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Cool

    Check out these guys -

    http://www.dynamicdrive.com/dynamici...menu/index.htm

    They have some awesome stuff, including the dynamic dropdown menu.

    it seems you haven't fully gotten into bed with php. you are also going to have to use javascript to post an 'onchange' action, so you might as well go dynamic.

    Code:
    <?
    $selection = "hotdogs"; 
    ?>
    
    <select id="<? echo $selection; ?>condiments" >
    <?
    ////below is mysql qeury stuff of course//
    connect();
    $pullmt = mysql_query("SELECT * FROM blah WHERE identity = '".mysql_real_escape_string($selection)."'") or die()
    while($resrow = mysql_fetch_assoc($pullmt))
    {
    echo "<option value=\"".$resrow['identity']."\">".$resrow['identity']."</option>";
    }
    mysql_close();
    ?>
    </select>
    Last edited by Falkon303; 03-27-2009 at 06:18 PM.
    document.write is document.wrong

Bookmarks

Posting Permissions

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