- Joined
- Dec 16, 2006
- Messages
- 33
- Reaction score
- 0
- Points
- 6
Hi guys,
I wonder can someone help here, a friend of mine wrote some Javascript code for me, but he has gone on holiday without telling me one thing - how to add it to my web page!
the code is:
I have a button which links to Page A but the code should introduce 2 checkboxes which when checked should re-direct to Page B or Page C.
Any help would be much appreciated
I wonder can someone help here, a friend of mine wrote some Javascript code for me, but he has gone on holiday without telling me one thing - how to add it to my web page!
the code is:
Code:
document.getElementById('gotoform').addEventListener('submit', function(e) {
for (var goto = '', i = 0; i < this.goto.length; i++) {
if (this.goto[i].checked) {
goto = this.goto[i].value;
break;
}
}
if (goto === 'admin') {
document.location = 'pageB.html';
} else if (goto === 'home') {
document.location = 'pageC.html';
} else {
alert('Invalid input');
}
e.preventDefault();
});
I have a button which links to Page A but the code should introduce 2 checkboxes which when checked should re-direct to Page B or Page C.
Any help would be much appreciated