Page 1 of 1

simple html drop down question

Posted: Wed Mar 08, 2006 1:01 pm
by rubberjohn
I have a drop down menu that is dynamically poplated from a database - that all works fine.

My problem is that I cannot get a title to appear in the drop down box which would say something along the lines of 'Make a selection...'

What I have managed is:
-to get one of the values to be displayed by default - but i dont want any of the values visible before the menu is opened.

-I have inserted a label into the list - however this is only visible once the drop down is opened - this is not good enough

-Declare 'Make a sellection...' as an option and set the 'selected' parameter - this would be perfect if there was a way to stop user selecting it and therefore submitting it.

Is there a way of stopping the user from selecting an option in this way and therefore preventing them from submitting it?

Can any one help me with this?

Thanks in advance.

i'll post the code i'm using

Code: Select all

$related_tags =  '<select name="related_tags" >Choose a tag';

while($saved_tags = mysql_fetch_array($sql_saved_tags, MYSQL_ASSOC)){

		$sql_get_tag_name = mysql_query("SELECT tag FROM f_tags WHERE tag_id = $saved_tags[tag_id]");

		while($get_tag_name = mysql_fetch_array($sql_get_tag_name, MYSQL_ASSOC)){

			$related_tags .= '<option value="">' . $get_tag_name['tag'] . '</option>';

		}





}
$related_tags .=  '</select>';

Posted: Wed Mar 08, 2006 1:14 pm
by darryladie
Make the code for your first option, this:

Code: Select all

<option selected="selected">Make a Selection</option>
Darryl :lol:

Posted: Wed Mar 08, 2006 2:24 pm
by rubberjohn
Cheers for the reply

I've already tried that - if the user leaves the menu as it is and hits submit, 'Make a Selection' gets submitted.

Posted: Wed Mar 08, 2006 2:39 pm
by darryladie
Well then you just need to put an if statement in your submit code, you code use Javascript or preferably PHP that just says if = "Make Selection..." then do nothing, else: run the function.

Darryl :idea: