PDA

View Full Version : parent function fires twice?!



dcorbett
Mar 30th, 2003, 04:36 PM
Using framesets, I'm calling a function in a parent frame. Here's the relevant code:

function save_input()
{
parent.parent.next_question1(sel==answer);
}

document.write('<FORM name="form1">');
document.write('<BR><INPUT type="button" name="b1" value="Submit" onClick="save_input()">');

This works, except every time the submit button is clicked, the function "next_question1" seems to fire twice.

Any ideas why?? Thanks.

Mr J
Mar 30th, 2003, 05:04 PM
I think you need to put the function call "onsubmit" rather than "onclick"




document.write('<FORM name="form1" onsubmit="save_input()">');
document.write('<BR><INPUT type="button" name="b1" value="Submit">');