Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: checkbox in a dropdown menu?

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

    Default checkbox in a dropdown menu?

    Hi,

    can u have a checkbox in a dropdown meny?

    and if whoe can u do it?
    Last edited by jes___per; 03-03-2009 at 07:56 AM.

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    I'm not sure I understand what you mean. If you mean that you can choose multiple options from a dropdown, you can use multiple, e.g.:
    Code:
    <select multiple="multiple">
      <option>One</option>
      <option>Two</option>
      <option>Three</option>
      <option>Four</option>
    </select>
    Now several options can be selected at the same time. If this isn't what you want, please try to be more specific.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  3. The Following User Says Thank You to Snookerman For This Useful Post:

    jes___per (03-04-2009)

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

    Default

    thx that is exacly what i ment

    cheers

  5. #4
    Join Date
    Mar 2009
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    but i cant gfet it to work:/

  6. #5
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Can you post a link to your site or the code you are using? We can't really help you without anything.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  7. #6
    Join Date
    Mar 2009
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    PHP Code:
    <html>
        <
    head>
        
            <
    title>Min Databas</title>
        
        </
    head></br>

        <
    body>
        <
    center>
        <
    img src="Earth.gif" alt="Earth"></br>
        </
    br>
            <
    form method="post" action="test.php">
            <
    b>Förnamn:</b> <input type="text" size="10" maxlength="40" name="för"></br>
            <
    b>Efternam:</b> <input type="efter" size="10" maxlength="10" name="efter"></br>
            </
    br>
            </
    br>
            <
    b>Ställ din Fråga:</br> </b><input type="checkbox" name="Select2"Fler Select alternativ</br>
            </
    br>
            </
    br>
            <
    b>Select:</b>
            <
    select name="Select"
            <
    option>Välj</option>
            <
    option value "*">Alla (*)</option>
            <
    option>Förnamn</option>
            <
    option>Efternamn</option>
            <
    option>Adress</option>
            <
    option>Telefon</option>
            <
    option>E-post</option>
            <
    option>Personnummer</option>
            </
    select>
            <
    select name="Select2"
            <
    option value "">Välj</option>
            <
    option>Förnamn</option>
            <
    option>Efternamn</option>
            <
    option>Adress</option>
            <
    option>Telefon</option>
            <
    option>E-post</option>
            <
    option>Personnummer</option>
            </
    select>
            <
    b>From:</b>
            <
    select name="From">
            <
    option>Välj</option>
            <
    option>DB</option>
            <
    option>DB2</option>
            </
    select>
            <
    b>Where:</b>
            <
    select name="Where"
            <
    option value "">Välj</option>
            <
    option value "*">Alla (*)</option>
            <
    option>Förnamn</option>
            <
    option>Efternamn</option>
            <
    option>Adress</option>
            <
    option>Telefon</option>
            <
    option>E-post</option>
            <
    option>Personnummer</option>
            </
    select>
            <
    select name="Where2">
            <
    option  value "">Välj</option>
            <
    option value "=">= Equal</option>
            <
    option value ">">> Greater than</option>
            <
    option value "<">< Less then</option>
            <
    option value ">=">>= Greater than or equal</option>
            <
    option value "<="><= Less than or eaual</option>
            <
    option value "<>"><> Not equal to</option>
            <
    option value "like">LIKE</option>
            </
    select>
            <
    b>Optional:</b>
            <
    input type="text" size="30" name="Optional"></br>
            </
    br>
            </
    br>
            <
    input type "submit" value "Skicka Fråga">
            </
    from>
        </
    body>
    </
    html
    PHP Code:
    <html>
        <head>
        
            <title>Test</title>
        
        </head></br>
        
        <body>
        <?php
        mysql_connect
    ("localhost""Sara""sara123") or die('Du är inte välkomen här!!!');
        
    mysql_select_db('test');
        
    // add the new information into the database
        /*    mysql_query("INSERT INTO info (Förnamn, Efternamn, Telefonnr)
            VALUES('$_POST[Förnamn]','$_POST[Efternamn]','$_POST[Telefonnr]') ")
            or die(mysql_error());
            echo "success in database entry.</br>";
            echo "<br />";
            echo "<a href=\"Inmatning.php\">Click here to return to the form page.</a>";
        */
        
    $Select=$_POST['Select'];
        
    $Select2=$_POST['Select2'];
        
    $From=$_POST['From'];
        
    $Where=$_POST['Where'];
        
    $Where2=$_POST['Where2'];
        
    $Optional=$_POST['Optional'];
        
        if (
    $Select==$_POST['Select'] && $Select2==$_POST['Select2'] && $From==$_POST['From'] && $Where==$_POST['Where'] && $Where2==$_POST['Where2'] && $Optional==$_POST['Optional'])
        {
        echo 
    "Data ur databas $From med följande SQL kod:""</p>";
        echo 
    "<b>Select</b> $Select$Select2 <b>From</b> $From <b>Where</b> $Where $Where2 $Optional";
            
    // Make a MySQL Connection
            
    $query "SELECT $Select$Select2 FROM $From WHERE $Where $Where2 '$Optional' "
            
            
    $result mysql_query($query) or die(mysql_error());
            echo 
    "<table border =1> </br>";
            if (
    $Select == '*')
            {
                echo 
    "<tr>
                    <th>Förnamn</th>
                    <th>Efternamn</th>
                    <th>Adress</th>
                    <th>Telefon</th>
                    <th>E-post</th>
                    <th>Personnummer</th>                
                    </tr>"
    ;

                while(
    $row mysql_fetch_array($result))
                {
                    echo 
    "<tr>".
                    
    "<td>".$row['Förnamn']."</td>".
                    
    "<td>".$row['Efternamn']."</td>".
                    
    "<td>".$row['Adress']."</td>".
                    
    "<td>".$row['Telefon']."</td>".
                    
    "<td>".$row['E-post']."</td>".
                    
    "<td>".$row['Personnummer']."</td>".    
                    
    "</tr>";
                }
                echo 
    "</table>";
            }
            else
            {
                echo 
    "<tr>
                    <th>
    $Select</th>                
                    <th>
    $Select2</th>
                    </tr>"
    ;

                while(
    $row mysql_fetch_array($result))
                    {
                    echo 
    "<tr>".
                        
    "<td>".$row[$Select]."</td>".
                        
    "<td>".$row[$Select2]."</td>".
                        
    "</tr>";
                    }
                echo 
    "</table>";
            }
        }
        else if (
    $Select==$_POST['Select'] && $From==$_POST['From'])
        {
        echo 
    "Data ur databas $From med följande SQL kod:""</p>";
        echo 
    "<b>Select</b> $Select <b>From</b> $From";
            
    // Make a MySQL Connection
            
    $query "SELECT $Select FROM $From"
                 
            
    $result mysql_query($query) or die(mysql_error());
            echo 
    "<table border =1> </br>";
            echo 
    "<tr>
                <th>
    $Select</th>                
                </tr>"
    ;

            while(
    $row mysql_fetch_array($result))
                {
                echo 
    "<tr>".
                    
    "<td>".$row[$Select]."</td>".    
                    
    "</tr>";
                }
            echo 
    "</table>";
        }
        else
        {
        echo 
    "...";
        }
        
    ?> 
        </body>
    </html>

  8. #7
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You didn't use multiple, add the highlighted to the dropdowns you want:
    Code:
    <select multiple="multiple">
      <option>One</option>
      <option>Two</option>
      <option>Three</option>
      <option>Four</option>
    </select>
    Good luck!
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  9. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    One thing you may want know about multiple, is that it can select multiple items. I don't know if thats what you want, so just letting you aware.
    Jeremy | jfein.net

  10. #9
    Join Date
    Mar 2009
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    ok but i cant get it to work

  11. #10
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Please post a link to the page on your site that contains the problematic script or attach your code so we can check it out and help you.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

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
  •