Please refer to the JSfiddle http://jsfiddle.net/uv7ng/3/
I have written a JS function and would like to assign an onclick event handler to the submit button “edit-next” on line 466 by using the following statement
document.webform-client-form-100.edit-next.onclick = ( function() {
}
);
webform-client-form-100 is the id of the form (line 84)
But firebug throws a SyntaxError: missing exponent error and the event handler is unassigned.
I tried document.node-100.edit-next.onclick, I still get the same error
(node-100 is the id of the page on line 59)
I’m not sure how else should I refer to the Submit button. Would appreciate any help. Thanks in advance.
Use document.getElementById:
Since the id is unique in the document anyway you can also use it directly:
I don’t completely understand the error, but
-is used for subtraction which is why you need to put your id in quotes.