PDA

View Full Version : Form's onsubmit is not working in the dialog



bandino
6 Jun 2007, 5:08 AM
Hi,

I have a page with html form loaded in the BasicDialog.
I tried to set onsubmit of the form:


<script>
function submFrm()
{
alert('Just testing');
return false;
}
</script>
...
<form id="form1" onsubmit="return submFrm();">....</form>

When I submit the form I get the error in firebug that tells that submFrm is not defined.

Can anyone help with this problem?

Regards

bandino
7 Jun 2007, 1:53 AM
Maybe I did not explain the problem precisely.

The onsubmit event handler of the form, from the above code, is working fine when the page is loaded into the browser. But when the page with the form is loaded into the BasicDialog, this does not work.
The error reported is that submFrm() is not defined.

Can anyone help me with this?

Thanks

tryanDLS
7 Jun 2007, 8:11 AM
That's b/c the method is not in scope. Adding inline function calls is generally a bad idea for this reason - you should use Ext to add a handler. If you need to learn more about scope, start with this thread (http://extjs.com/forum/showthread.php?t=6336&highlight=scope) and also the sticky thread - 'javascript newbies'.