SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Javascript and mysql

    Hello!
    I'm not very confortable with javascript and need some help.
    I have the following scipt on my php page:

    PHP Code:
    <?php  

    $resultado
    =mysql_query("select * FROM associated  ORDER BY enterprise asc") or die("Erro ao listar tabela");  
        echo (
    "<table width=\"95%\" border=\"0\">");  
        echo 
    "<tr>";  
        echo 
    "<td class=\"texto\"><form name=\"associated\" method=\"post\" action=\"\" ><select name=\"list\"> <option value=\"\" selected>Associated List</option>";  
        while (
    $registo=mysql_fetch_row($resultado))  
        {  
            echo 
    "<option value=\"$registo[1]\">$registo[1]</option>";  
        }  
        echo 
    "</select><br>";  
        echo 
    "<input type=\"text\" name=\"adress_field\"><br>";  
        echo 
    "<input type=\"text\" name=\"sector_field\"><br>";  
        echo 
    "<input type=\"submit\" name=\"Submit2\" value=\"Submit\">";  
        echo 
    "</form></td>";  
        echo 
    "</tr>";  
        echo (
    "</table>");  
          
        
    mysql_close();  
          
    ?>
    Well, I know this is a javascript forum but what I need is a javascript.
    As you may see, the listbox has dynamic content from a Mysql table with the "id, enterprise, adress, sector" fields.
    I now wanted to chose an enterprise from the list box and the two text fields below would be automatic filled with the correspondent data from the mysql table.
    Hope this is understandable...
    Thanks in advance!

  2. #2
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    javascript and html (technically) can't pull in information dynamically from a database.

    however, 3 solutions for this...

    1. simply refresh the page based on what the user picks from the pulldown menu and re-populate the coresponding pulldown. this is the most common approach.

    2. if the data isn't TOO large, you could store what you get out of mysql into javascript arrays and display the info according to that.

    3. mess with the new fad and craze of the httprequest to populate the pulldown

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jesus... I can't figure out any way arrond of your solutions... :'( Could you be more specif? The first solution seems fine but I cant get it to work...
    Thanks a lot


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
  •