Name: Anonymous 2010-12-14 11:53
How do you reference a button's field? (name, in this case)
I want to change the link that the "link" id is set to, based on which of the 3 buttons is clicked.
I want to change the link that the "link" id is set to, based on which of the 3 buttons is clicked.
<script>
function changeLink()
{
switch(document.btnform.WHATTOPUTHERE?)
{
case "x":
linkvar = "xml.htm";
break;
case "j1":
linkvar = "java.htm";
break;
default:
linkvar = "java2.htm";
}
document.getElementById("link").setAttribute("href", linkvar);;
}
</script>
<body>
<a id="link">Go To Page</a>
<br /><br />
<form id="btnform">
<input type="button" name="x" value="Set Link to XML Page" onclick="changeLink();" /><br />
<input type="button" name="j1" value="Set Link to JS 1 Page" onclick="changeLink();" />
<input type="button" name="j2" value="Set Link to JS 2 Page" onclick="changeLink();" />
</form>