Page 1 of 1

dropdwon list

Posted: Thu Jan 26, 2006 10:15 pm
by Maluendaster
I want to create a downdrop of all the Galleries i have in the database.... and the babes showing in the dropdown will be linked to their specific URL....

The tables i think i have to use is Name and URL , don't know how to do this..

anyone can give me a hint,, i'm a newbe...

thanks

Posted: Thu Jan 26, 2006 10:29 pm
by josh
I hate to make such a meaningless post but is there something I'm missing, what is it you want to do? What does your database have in it, by "downdrop" you mean the form 'select' element? What do you mean by picture in the dropdown, I doubt you can put a picture in a standard html select element.

Posted: Thu Jan 26, 2006 10:47 pm
by feyd
you actually can be an image (in the background) of each option, however altering the dimensions of the option to reflect it will not be calculated into the display, so it's not a good idea to do it in that fashion.

Posted: Fri Jan 27, 2006 12:17 pm
by Maluendaster
ok, i guessi didn't make mysqslf clear, I don't want any images on the dropdown, i just want the names and when you select a name, it redirects to the gallery...

The names are in a table called galeria which has 3 fileds, Name, ID and URL...

I want to be able to automaticly (spell) appear in the dropdown list when i add a new gallery...

Posted: Fri Jan 27, 2006 12:38 pm
by feyd
searching around for jumpbox or similar "jump box" kinda things.

Here's the basics: you use the onchange event of the select element to read the url found in the newly selected option then change the document.location.href property. :)

Posted: Fri Jan 27, 2006 3:22 pm
by raghavan20

Code: Select all

<form name = 'formChangeLocation'>
<select name = 'changeLocation' onchange = 'document.location.href = frmChangeLocation.changeLocation.value'>
	<option value = '<?php echo $url; ?>'>
		<?php echo $value; ?>
	</option>
</select>
</form>
but the problem with the code might be, it does not recognize selection of first option in a select control. I think for the same reason even in phpBB forums use a GO button to trigger event.

Posted: Fri Jan 27, 2006 3:40 pm
by feyd
The go button is provided for backward compatibility. Typically, the first element is a null value, it simply states they should make a selection or something similar. Basically, it's filler.

Posted: Fri Jan 27, 2006 5:18 pm
by Burrito
indeed Feyd:

you should check that the value is not null before you do anything with the event:

ex:

Code: Select all

<select name="blah" onChange="if(this.value != "") someFunction();">

Posted: Fri Jan 27, 2006 11:42 pm
by josh
If you set the current page in the drop-down to selected you won't have any problems, just thought I'd throw that in there

(if the current page is not one of the options you'd still need to have "----" as the first option or something similar)