68 users online (0 members and 68 guests)  


  Results 1 to 5 of 5

Related

  1. Replies: 0
  2. Replies: 4
  3. How Do I Create A Music Drop-down List?    Forum: HTML Forum
    Replies: 1
  4. javascript drop down menus prob    Forum: Website Scripts Forum
    Replies: 11
  5. Setting cookies to remember drop down list    Forum: Website Scripts Forum
    Replies: 3
  1. #1
    TBird2424's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Location
    Pittsburgh, PA
    Posts
    7

    Talking JavaScript - Form Drop Down List

    Hello, I am new to JavaScript and I am trying to develop a tool for my wife's work. Right now I am trying to figure out how to get all the users in a data base to show up in a drop down selection box in a form. This way if any new users are added between visits to the webpage the new users will be automatically added to the list.

    Anyone have any direction for me to go or know where I mgiht find some help for this.

    Thanks in advance.

    Jeff Moore(TBird2424)

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi there,

    Heres an example I found:

    Code:
    <?php
    
    
    
    function generate_box() {
    
        $sql = "SELECT * FROM xxxx";
    
        $result = mysql_query($sql);
    
        $entries = mysql_num_rows($result);
    
    
    
        for($n = 0; $n <= $entries; $n++) {
    
            $sql = "SELECT * FROM xxxx WHERE ID = $n";
    
            $result = mysql_query($sql);
    
            while ($info = mysql_fetch_array($result)) {
    
                foreach( $info AS $key => $val ) {
    
                    $$key = stripslashes( $val );
    
                }
    
                $options .= "<option value=\"-1\">$name</option>";
    
                $options .= "<option value=\"-1\"></option>";
    
              }
    
        }
    
        return $options;
    
    }
    
    
    
    $options = generate_box();
    
    
    
    ?>
    
    <form method="get" name="forum_select" action="search.php"><table cellspacing="0" cellpadding="0" border="0">
    
    	<tr>
    
                    <td><span>Search By: 
    
    <select name="by">
    
    <? echo "$options"; ?>
    
    <input type="submit" value="go"></span></td>
    
    	</tr>
    
    </table></form>
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    TBird2424's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Location
    Pittsburgh, PA
    Posts
    7
    Quiet Dean, I am a little confused here. Is this PHP code or JavaScript? What is the difference? Sorry but I am truely a Nooby on JavaScript and still learning the many different types of code.

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hiya,

    Its actually PHP. My bad, I paid no attention to where you had posted.

    You cannot access a database using only JavaScript, unfortunately. But you can by using a server-side language like PHP. If you are on a windows server, you may be better off using ASP or ASP.net.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    TBird2424's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Location
    Pittsburgh, PA
    Posts
    7

    Talking

    Thanks for the reply. At least that gives me a direction to go now.

    Thanks for your help again.



Tags for this Thread