Click to See Complete Forum and Search --> : Insert variablestring in onclick attribute in <area> tag


Wallykid
07-16-2003, 01:44 PM
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()">

Khalid Ali
07-16-2003, 05:21 PM
Is your intent to change the href dynamically?..
"this.href = 'page_'+document.formName.selectName.opetions[document.formName.selectName.selecteIndex].value+'.html'"

should do it

Wallykid
07-17-2003, 09:44 AM
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