Click to See Complete Forum and Search --> : onClick in form does not work


Thomas2
10-14-2003, 04:08 AM
Hi,

I put an onClick event handler in the Input-tag of form which should trigger a javascript function if the form is submitted but nothing happens. I also tried using onSubmit in the Form-tag but it does not work either. Using onClick in the Form-tag or Textarea-tag runs the script when I put the cursor in the Textarea field which is not what I want however.
It all works OK if the function is triggered from outside the form (e.g. from a link).

Any ideas what is going on here ?

Charles
10-14-2003, 04:49 AM
Originally posted by Thomas2
Any ideas what is going on here ? How on earth would we have any way of knowing without access to your page?

Thomas2
10-14-2003, 09:45 AM
Originally posted by Charles
How on earth would we have any way of knowing without access to your page?

The code (which is part of a chatroom script) is basically as follows

<HTML>
<HEAD>
<SCRIPT Language="Javascript" src="refresh.js" type="text/javascript"> </SCRIPT>
</HEAD>
<BODY>
<form method="post" action="input.php" >
<textarea name="txt" type="text" rows="5" cols="52" id="txt"></textarea>
<input type="submit" name="Submit" value=" Chat! " onClick="refr()">
</form>
</BODY>
</HTML>

where refresh.js is given by

function refr() {
parent.mainFrame.location.href="messages.php";
}

This should refresh the content in mainFrame but it doesn't (there are no javascript error messages of any kind). The function is actually called (I checked it by putting in a javascript alert) but it does not refresh the frame. As mentioned, it works perfectly OK if the javascript is called outside the form.

Thomas2
10-15-2003, 05:25 AM
Still nobody with any suggestions ?