Forum Moderators: open
function buttonpress()
{
for(v=0 ; v<=5; v=v+1)
{
if(document.forms[0].button/element[v].selected)
{
variable = document.forms[0].button/element[v].value;
}
}
var newlink = variable + '.html';
parent.frames[2].location= newlink;
}
But i don't know the button/element[v] array which means i have to refer to their names such as button1, button2, etc. I can't do it this way with a a for statement because the names are different. Maybe an button array or a struct?
Thanks
Why not just pass an object reference to the function from each button?
<script type="text/javascript">
<!--
function buttonpress(obj)
{
variable=obj.id
var newlink = variable + '.html';
parent.frames[2].location= newlink;
}
//-->
</script>
</head>
<body>
<button id="newpage1" onclick="buttonpress(this)">newpage1</button>
<button id="newpage2" onclick="buttonpress(this)">newpage2</button>
</body>
You can set up a global click-handling function that accesses the clicked element instead, but this is easier to implement.
ajkimoto