/    Sign up×
Community /Pin to ProfileBookmark

Insert variablestring in onclick attribute in <area> tag

The following is my code,

//This javascript obtain the value selected at the
//dropdown box and assign it to yearval.

<script language=”JavaScript”>
function assignyear()
{
var yearval;
yearval = document.calform.year.value;
return yearval;
}
</script>

//This is the dropdown box
<td valign=”top”>
<select id=”year” name=”year” size=”1″>
<option selected value=”2003″>2003
<option value=”2004″>2004
</select>
</td>

//This is mapping for a graphic that when clicked on, it will link to the page january_2003.htm

<map name=”cal” id=”cal1″>
<area shape=”rect” coords=”96,1,156,29″ href=”january_2003.htm” alt=”January” onClick=”return assignyear()”></map>

Onclick, i like to append the value of dropdown box to the href attribute. Something like

<area shape=”rect” coords=”96,1,156,29″ href=”january_(yearval).htm” alt=”January” onClick=”return assignyear()”>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJul 16.2003 — Is your intent to change the href dynamically?..

"this.href = 'page_'+document.formName.selectName.opetions[document.formName.selectName.selecteIndex].value+'.html'"

should do it
Copy linkTweet thisAlerts:
@WallykidauthorJul 17.2003 — Yes i am trying to change the linke dynamically. I have a graphic, and i am using <usemap> to map the the graphic, and i use the <area> tag to create the link so that when i click on the graphic it will go to different months calendar depending on where they click on the graphic. Let say they click on Jan, and they chose 2003, then i need to tailor the link to bring them to january_2003.htm. I am new to javascript, can you explain how i can implement that to my code above?

"this.href = 'page_'+document.formName.selectName.opetions[document.formName.selectName.selecteIndex].value+'.html'"

Where do i put this? In here...

<area shape="rect" coords="96,1,156,29" "this.href = 'page_'+document.formName.selectName.opetions[document.formName.selectName.selecteIndex].value+'.html'">

What is the 'page_' thing?

Thanks for the reply
×

Success!

Help @Wallykid 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.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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