Jump to content

Link to specific choice in drop down form?


Recommended Posts

Hi all,I run a website for an organisation that is an umbrella group for 150ish organisations.I have included contact details for each organisation on the member directory on our website, but I have not included email addresses to date. The reason for this is the age-old worry about spam. I wouldn't want our members to get junk mail because of me...So to this end I want to include a 'contact us' form. I'm quite happy to create this and include each member as a choice in the drop down list.BUT because there's 150ish members that makes a looooong drop down list. What I would like to do is have a listing like this:Member nameaddressemail usThe "email us" link would take you to the contact us form - *with the member auto-selected from the drop down list*. I don't know how to do this... do you?Any help welcome.Cheers,Mike

Link to comment
Share on other sites

you could make email us a link to your contact page, and pass it an argument via GET, i.e.


where memberName is literally the name of that member.part of the beginning of the contact.php would be to have a list of all your memberNames, and you write a loop to output the drop down list, and for iteration, you could check if the passed memberName matches the current memberName being iterated, and if it, add


to that particular option tag.i.e.

<?php//assuming you have an array of members already$dropdown = '';$memberName = $_GET['memberName'];for($i = 0, $l = count($members); $i < l; $i++){  $name = $members[$i];  $dropdown .= "<option value'" . $name . "'";  if($name == $memberName){	$dropdown .= "selected='selected'";  };  $dropdown .= "'>" . $name . "</option>\n";};

and then you can echo/print that right out anywhere on the page in between some <select> tags.

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...