I am having trouble posting a form through javascript. It seems to post, but
it posts to the directory and not the page. It also does the same if I try
to click a button through javascript (However, if I click the button
directory, it works fine).
I'm using Asp.Net 2.0. Here's the form tag:
form name="aspnetForm" method="post" action="MlsNumberSearch.aspx"
onkeypress="javascript:return WebForm_FireDefaultButton(event,
'ctl00_cb_btnHandleEnterKey')" id="aspnetForm">
Here's the javascript:
function TestHiddenButton() {
alert(document.forms[0].action) //This works fine!
alert(document.forms[0].method) //This works fine!
alert(document.forms[0].name) //This works fine!
document.forms[0].submit() //This does not post directly to the
form!??
}
Does anyone know why it's not posting correctly? Your help is greatly
appreciated!!!
I am still having the problem, but I think I'm starting to somewhat narrow
this down. The code in my previous post still does NOT work, but if I submit
the page when the page loads (see example below), the page submits perfectly.
The code looks like this:
<script language="javascript" type="text/javascript">
//ok, let's try it this way...
document.forms(0).submit()
</script>
Could this be related to a XP SP2 security thing? Any help is greatly
appreciated!!!

Signature
Steve
> I am having trouble posting a form through javascript. It seems to post, but
> it posts to the directory and not the page. It also does the same if I try
[quoted text clipped - 19 lines]
> Does anyone know why it's not posting correctly? Your help is greatly
> appreciated!!!
Steve - 17 Nov 2005 20:28 GMT
I finally figured out the problem!!! The href attribute MUST have something
in there, even if it's dummy data for the data to post.
This:
[code]
<a href="" onclick="javascript:ClickButton()">Click me to submit the page
through clicking the button</a>
[/code]
should be:
[code]
<a href="#DUMMY" onclick="javascript:ClickButton()">Click me to submit the
page through clicking the button</a>
[/code]

Signature
Steve
> I am still having the problem, but I think I'm starting to somewhat narrow
> this down. The code in my previous post still does NOT work, but if I submit
[quoted text clipped - 32 lines]
> > Does anyone know why it's not posting correctly? Your help is greatly
> > appreciated!!!