Forum Moderators: open

Message Too Old, No Replies

access form object via its elements

Internet Explorer issue

         

ayushchd

6:47 am on Jun 18, 2010 (gmt 0)

10+ Year Member



Hi,

If in the form tag, I can access the form object by "this", for eg,
<form name="a" id="a" onSubmit="func(this)">

How do I call the function via an element of the same form?

For eg,
<input onClick="func(this.form)"> (This works in Chrome and FF but not in IE)

How do I do it in IE?

Fotiman

3:33 pm on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It works for me in IE. Here's my test case:


<html>
<head>
<title>Form Test</title>
</head>
<body>
<form name="a" id="foo" onsubmit="func(this);">
<div><input id="bar" onclick="func(this.form);"></div>
</form>
<script type="text/javascript">
function func(el) {
alert(el.id); // Should be 'foo'
}
</script>
</body>
</html>