Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   HTML / XHTML / CSS (http://www.programmingforums.org/forum27.html)
-   -   DropDown Box . (http://www.programmingforums.org/showthread.php?t=10881)

ASHORY Jul 29th, 2006 5:31 PM

DropDown Box .
 
Hi ,

Please How can i make links in a drop down box ,

as an example :

i have the entries "1,2,3"
so i want when i click on 1 it goes to a page and 2 to anther page etc ..

please any one help me

B3TA_SCR1PT3R Jul 29th, 2006 6:29 PM

http://www.google.com/search?hl=en&q...=Google+Search

[html]
<form name="numz">
<select name="menu" onChange="location=document.numz.menu.options[document.numz.menu.selectedIndex].value;">
<option value="http://google.com">google</option>
<option value="http://yahoo.com">yahoo</option>
<option value="http://programmingforums.org">pfo</option>
</select>
</form>
[/html]

//edit, didnt really read your post, fixed it to link

ASHORY Jul 30th, 2006 8:12 AM

oooh , so the value can be a link to anther site , i didnt know that i thought its a only a value of the variable in the option command

Arevos Jul 30th, 2006 8:36 AM

Quote:

Originally Posted by ASHORY
oooh , so the value can be a link to anther site , i didnt know that i thought its a only a value of the variable in the option command

It is only a value. The javascript in the onChange attribute does the magic:
:

onChange="location=document.numz.menu.options[document.numz.menu.selectedIndex].value;"

ASHORY Jul 30th, 2006 3:26 PM

ok so how can i make the same example but with a popup window

Sane Jul 30th, 2006 3:34 PM

Change the "location = " to a function call to "popup".

This is an adaptation of DaWei's popup function.

:

function popup(wURL,w,h,wID)
{
    var specs = "width="+w+",height="+h+",top=10,left=10," +
                "screenx=10,screeny=10," +
                "resizable=yes,scrollbars=no,statusbar=no";
    popWin = open(wURL, wID, specs);
    popWin.focus ();
    return popWin;
}


And in that function call, the first paramter will be "document.numz.menu.options[document.numz.menu.selectedIndex].value", the second and third is the width/height of the popup, and the fourth is a unique identifier to make multiple popups in the same/different popup window.

If you're familiar with javascript, it should be quite easy to set up. If you're not, post back and I can give a little more information on how abouts to do it.

But don't give up right away just because I said that . . .

ASHORY Jul 31st, 2006 2:45 PM

thanks sane ,

really iam not good in javascript but i think that i got it , any way i'll post here if i needed any other help


All times are GMT -5. The time now is 12:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC