Using php in a drop down list...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

Using php in a drop down list...

Post by orbdrums »

I want to create a drop down that will use a static link but pass a value from a dynamic list. I can't seem to get this to work without using a submit button. Here is an example of my code:

Code: Select all

        <form id="FriendForm" name="FriendForm" method="post" action="friend-display.php">
        <select name="v_friend_of_id" id="v_friend_of_id">
        <option value=0>Select Friend</option>
<?
         $result = mysql_query($query_details);
        while ($row = mysql_fetch_assoc($result))
        {
            if ($row['friend_of'] == $v_mbr_id)
            {
            	$v_friend_of_id = $row['mbr_member_id'];
             } else {
            	$v_friend_of_id = $row['friend_of'];
             }
?>
            <option value="<? echo $v_friend_of_id; ?>"><? echo $v_friend_request_fname." ".$v_friend_request_lname; ?></option>
<?
        }
?>

        </select>
        <input type="submit" name="Submit" value="Visit Friend" />
Is there a way to accomplish this without using the submit button? I want to avoid another mouse click. Thanks for any assistance.
C
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Using php in a drop down list...

Post by requinix »

The only question I could get from that was how to submit the form automatically without having to click the button. Is that it?

Code: Select all

<select name="v_friend_of_id" id="v_friend_of_id" onchange="this.form.submit();">
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

Re: Using php in a drop down list...

Post by orbdrums »

Yes. I don't want users clicking on two places when it's not necessary...
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Using php in a drop down list...

Post by requinix »

Okay. So... problem solved?
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

Re: Using php in a drop down list...

Post by orbdrums »

Awesome!! Thanks for your help!
Post Reply