Thursday 8 December 2011

HTML/Javascript issue

HTML/Javascript issue

Hi guys,

A friend has given me some javascript but I don't know much about Javascript as I only do CSS/HTML. What I want to know is how to incorporate it into my Home Page.

the script 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 = 'admin.php';
    } else if (goto === 'home') {
        document.location = 'index.php';
    } else {
        alert('Invalid input');
    }
    e.preventDefault();

The story is I have a custom button which links to say page A, what I wanted was 2 checkboxes that when either is checked the button will go to page B or page C.

Any ideas? :?

No comments:

Post a Comment