Web Analytics Made Easy -
StatCounter Replace buttons with dropdown menu - CodingForum

Announcement

Collapse
No announcement yet.

Replace buttons with dropdown menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Replace buttons with dropdown menu

    Hi,
    I'm using this form to call 3 different scripts using seperate buttons, I would like to change the 3 buttons to a single dropdown menu, any help is appreciated. Thanks Joe

    [<?php]

    if ($_POST)
    {
    if ($_POST['b1']);
    else if ($_POST['b2']);
    if ($_POST['b']);
    else if ($_POST['b3']);
    }
    else
    {
    echo ("<center><form name=src action=A_Snoopy.php method=post>");
    echo ("<input type=text size=55 name=url value=''/>");
    echo ("<button name='b1' type='submit' value='a'>View Links</button>");
    echo ("<button name='b2' type='submit' value='b'>View Source</button>");
    echo ("<button name='b3' type='submit' value='c'>View Meta Tag</button></center>");
    }
    [/?>]

  • #2
    PHP Code:
    echo "
    <center>
    <form name='src' action='A_Snoopy.php' method='post'>
    URL: <input type='text' size='55' name='url' value='' /><br />
    <select name='b'>
    <option value='a'>View Links</option>
    <option value='b'>View Source</option>
    <option value='c'>View Meta Tag</option>
    </select>
    <input type='submit' name='submit' value='process it'>
    </form>
    </center>
    "

    To view options ...
    PHP Code:
    $option=$_POST['b'];
    switch (
    $option){
        case 
    "a":
            
    // view links
            // do something
            
    break;
        case 
    "b":
            
    // view source
            // do something
            
    break;
        case 
    "c":
            
    // view meta tags
            // do something
            
    break;
    }

    ?> 

    Comment


    • #3
      Try it and worked perfect. Regards Joe

      Comment


      • #4
        Papajo ...

        If you want to get fancy, you could use a cookie to remember
        what option they picked. It would remember the same option
        every time (on that PC).

        Comment

        Working...
        X