all groups > dotnet jscript > november 2005 >
You're in the

dotnet jscript

group:

javascript post



javascript post Steve
11/15/2005 10:56:02 AM
dotnet jscript: 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!!!

--
RE: javascript post Steve
11/16/2005 2:09:32 PM
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!!!

--
Steve


[quoted text, click to view]
RE: javascript post Steve
11/17/2005 12:28:37 PM
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]

--
Steve


[quoted text, click to view]
AddThis Social Bookmark Button