Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Referencing a Button form element

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.


<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>

Name: Anonymous 2010-12-14 12:04

Anyway
document.btnform.WHATTOPUTHERE?
does that even work?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List