Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submit form in JS function not working

Status
Not open for further replies.

Einstein47

Programmer
Nov 29, 2001
737
US
Hey everyone,

I have a function that calls the page's form.submit() method, but I keep getting an error message "Object doesn't support this property or method". I know that this function works because I took it from another page. Here's the code - any suggestions on what to look for?
Code:
function remove( jrId, htId )
{
  var msg = "Press OK to remove the record, or\npress Cancel to return to the maintenance page"
  if (confirm(msg))
  {
alert("inside remove block: jrId="+jrId+", htId="+htId)
    var myForm = document.forms[0]
    myForm.judgeroleid.value = jrId
    myForm.hearingtypeid.value = htId
    myForm.submit()
  }
}
And this is the link that calls it:
Code:
<A HREF=&quot;#&quot; onclick=&quot;remove(4,30);&quot; tabindex=&quot;-1&quot;> remove </A>

Einstein47
(&quot;Vision without action is a daydream - Action without vision is a nightmare. Japanese Proverb&quot;)
 
Have you narrowed it down, for example document.forms[0].submit() instead of myForm.submit() or tried in different browsers? Are errors being generated?

This would eliminate some guesswork...

&quot;News and views of some obscure guy&quot;
 
I found it!!!

the name of the submit button was &quot;submit&quot;. and that was overriding the submit() function of the form. I just removed the name of the button and volia' it worked as designed.

We learn two things from this - JavaScript is case sensitive (using &quot;Submit&quot; with a capital S didn't affect the method submit() - I tried that after). So make sure you name your form elements using Capitol letters when errors are found.

- second thing is avoid reserved words like the plague. Don't ever name a button &quot;submit&quot;, or a form element &quot;name&quot; or &quot;length&quot; or any other reserved word - there will not be any warning until your page stops working the way all the other pages work.

Those who don't learn from history will be doomed to repeat it!

Einstein47
(&quot;Vision without action is a daydream - Action without vision is a nightmare. Japanese Proverb&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top