SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Singapore
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP cum Javascript don't work !!

    PHP Code:
    <select name="cat_listbox" onchange= "javascript:Document.submit()">; 
            <?php  
             
            
            $sql 
    "SELECT distinct Category_Name from Category ORDER BY Category_Name asc";
            
    $result mysql_query($sql);
            while(
    $menu mysql_fetch_array($result))
             { 
             
    $menu1$menu['Category_Name'];
      
             echo 
    '<option value="'.$menu1.'">'.$menu1.'</option>';
                }
            
    ?>
            </select>
            
            <select name="subcat_listbox" onchange= "javascript:new()">; 
            <?php  
             
            
    //$catID = $_POST("cat_listbox.value");
            
            
    $sql "SELECT distinct Sub_Category_Name from Sub_Category ORDER BY Sub_Category_Name asc
                    WHERE Sub_Category_ID = '"
    .$catID."'";
                    
            
    $result mysql_query($sql);
            while(
    $menu mysql_fetch_array($result))
             { 
             
    $menu1$menu['Sub_Category_Name'];
      
             echo 
    '<option value="'.$menu1.'">'.$menu1.'</option>';
                }
            
    ?>
            </select>
    hi guys, i trying to create a 2 level listboxes where the contents of the 2nd listboxes depends on the value of the 1st listbox.i was trying to tweak around with the javascript, getting it to submit so that i can retrieve.but the data doesn't seen to be submitting

    I been up all nite trying to figure it out

    many thanks for your advises !!

  2. #2
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Submit() needs to be called on a form, not a whole document. You might also like to note, when using an event handler, like onchange, it isn't necessary to use the javascript&#058; pseudo-URL. Needless to say, for submission to actually occur, the form will need an appropriate action attribute.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    onChange="document.myForm.submit();"
    cheers


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
  •