DHTML: Submit form in a DIV tag returns a page not found error

<DIV onClick="document.form1.submit();">Test</DIV>

When I click on that particular DIV, it redirects me to a "undefined" page. That why i get a page not found error. But when I do a alert(document.form1.action) before the submit command. It returns the correct page. If I put the same javascript on a different control for e.g. a button, it works fine.
Who is Participating?
venkateshwarrConnect With a Mentor Commented:
This one works for me...

<form action="http://www.google.com/" name=form1>
  <input type=hidden name=test value=1>
<DIV onClick="document.form1.submit();">Test</DIV>

may be there is problem in your form action

Your search criteria for google is invalid u need to set the name attribute with correct keywor here u go with the right result keyword.

<form action="http://www.google.com/search" name=form1>
  <input type=hidden name=q value=a>
<DIV onClick="document.form1.submit();">Test</DIV>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.