Page 1 of 1

Using php in a drop down list...

Posted: Fri Jul 26, 2013 7:42 pm
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

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

Posted: Fri Jul 26, 2013 8:31 pm
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();">

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

Posted: Fri Jul 26, 2013 10:44 pm
by orbdrums
Yes. I don't want users clicking on two places when it's not necessary...

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

Posted: Fri Jul 26, 2013 11:41 pm
by requinix
Okay. So... problem solved?

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

Posted: Sat Jul 27, 2013 1:41 pm
by orbdrums
Awesome!! Thanks for your help!