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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Form.Action in Javascript - not submitting to correct page

Status
Not open for further replies.

jjoy123123

Programmer
Oct 22, 2002
20
US
I want to submit my form (using Javascript) when a user clicks on the Save button. However, its not submitting to the Save_Call.asp page - it's just submitting the form to the page I am on. I know that the submit code is running because I can watch the page refresh. If it's making it to the submit code, then it must have read the line before it where I'm setting the action variable. Why isn't it going to Save_Call.asp though?

FYI - The reason I'm submitting through JavaScript is because I'm actually submitting to a different page if they click a different button.


JAVASCRIPT FUNCTION ---------------------------------------------------------------------
<script language=&quot;JavaScript&quot;>
function SaveForm()
{
document.DetailForm.action == &quot;Save_Call.asp&quot;;
document.DetailForm.submit();
}
</script>

FORM TAG --------------------------------------------------------------------------------
<Form NAME=&quot;DetailForm&quot; id=&quot;DetailForm&quot; method=&quot;POST&quot;>
<input type=&quot;button&quot; name=&quot;Save&quot; onclick=&quot;SaveForm()&quot; value=&quot;Save&quot;>
 
add action=&quot;&quot; to the form tag
more reference thread216-29369 and the forum216 javascript forum

_____________________________________________________________________
onpnt2.gif
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
[/sub]
 
I've never had a problem with not having the action set in the <form> tag, but that doesn't mean that I did it correctly, either. Another thought may be to tweak your javascript because I believe that you only need one equals sign when setting the variable. Take out the second equal (=) sign when setting the form action to the new location.

<script language=&quot;JavaScript&quot;>
function SaveForm()
{
document.DetailForm.action = &quot;Save_Call.asp&quot;;
document.DetailForm.submit();
}
</script>


-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Chopstik! star for that one. good eye. you're starting to get pretty darn good at this.

feels cool, don't it [smile]



_____________________________________________________________________
onpnt2.gif
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
[/sub]
 
Even idiots can be right every once in a while. ;-) Thanks!

-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
That worked, thank you!!! That was driving me crazy - no one noticed it before now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top