/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Anchor tags within <SELECT> dropdown list

Hi everyone,
I am a newbie to web designing and i wanted to know how can i add an anchor tag to the options of <SELECT> tag. The whole idea is when the user clicks an option from the dropdown list, it should navigate to a table within the same webpage. Another option->another table.
Thanks lot!

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 13.2009 — &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;dropdown bookmarks&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;
window.onload=function() {
// hide list
var objBM=document.getElementById('bookmarks');
objBM.style.display='none';
// create dropdown
var container=document.createElement('div');
var sel=document.createElement('select');
container.appendChild(sel);
objBM.parentNode.insertBefore(container, objBM.nextSibling);
// onchange
sel.onchange=function() {document.location=this.value;};
// fill options
var aBM=objBM.getElementsByTagName('a');
sel.options[0]=new Option('select an option', '');
for(var i=0; i&lt;aBM.length; i++) {
sel.options[i+1]=new Option(aBM[i].firstChild.data, aBM[i].href);
}
};
&lt;/script&gt;

&lt;style type="text/css"&gt;
div[id] {margin:20em 0;}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;ul id="bookmarks"&gt;
&lt;li&gt;&lt;a href="#one"&gt;one&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#two"&gt;two&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#three"&gt;three&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id="one"&gt;bookmark 1&lt;/div&gt;
&lt;div id="two"&gt;bookmark 2&lt;/div&gt;
&lt;div id="three"&gt;bookmark 3&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@koolz33authorApr 13.2009 — It works! Thanks a lot.. ?
×

Success!

Help @koolz33 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...