469,903 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Location.replace - form

JHB
Hi,

How can I do a location.replace when I use a form, like when I use a href?

This works.
<a href="Ny HTML-side20.htm"; method="post" id="frm" name="BrugerHovedSide"
onsubmit="location.replace(this.href);" >
<input class="ok" type="submit" value="Opfrisk data" id=submit1
name=submit1>
</a>

this dosen't work
<form action="Ny HTML-side20.htm"; method="post" id="frm"
name="BrugerHovedSide" onsubmit="location.replace(this.href);" >
<input class="ok" type="submit" value="Opfrisk data" id=submit1
name=submit1>
</form>
TIA
Jørn
HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<a href="Ny HTML-side20.htm"; method="post" id="frm" name="BrugerHovedSide"
onsubmit="location.replace(this.href);" >
<input class="ok" type="submit" value="Opfrisk data" id=submit1
name=submit1>
</a>

<form action="Ny HTML-side20.htm"; method="post" id="frm"
name="BrugerHovedSide" onsubmit="location.replace(this.href);" >
<input class="ok" type="submit" value="Opfrisk data" id=submit1
name=submit1>
</form>

</BODY>
</HTML>
Jul 23 '05 #1
2 8187
JHB wrote on 15 jul 2005 in comp.lang.javascript:

[Please do not send html on usenet, this is not email]
How can I do a location.replace when I use a form, like when I use a
href?
You cannot really.
This works.
Not really
<a href="Ny HTML-side20.htm"; method="post" id="frm"
The ; has no function here, it is wrong html.
method="post" has no function in <a >
name="BrugerHovedSide" onsubmit="location.replace(this.href);" >
<input class="ok" type="submit" value="Opfrisk data" id=submit1
name=submit1>
</a>
onsubmit does not have a function in <a >
you need a <form > for onsubmit

try for <a >:

onclick="location.replace(this.href);return false;"
preventing the href executing while javascript is active in a browser.
this dosen't work
Doesn't it?
<form action="Ny HTML-side20.htm"; method="post" id="frm"
name="BrugerHovedSide" onsubmit="location.replace(this.href);" >
The ; has no function here.

The onsubmit should have a return false;
see above, same syntax as onclick

However the onsubmit false will not execute the form, so no <input >
values will be sent.
<input class="ok" type="submit" value="Opfrisk data" id=submit1
name=submit1>
</form>


Conclusion:

1 For sending form input data the form has to go to the action="" page by
that way.

2 Onsubmit can only be used to prevent execution of the <form> otr to do
some local actions or both.

try:

<form action='' method='post'
onsubmit ='return confirm("Really send this?")'>
<input name='data' value='myValue'>
<input type='submit'>
</form>

This will only execute the form and the data value
if confirm() returns true after clicking it's 'Yes' button/
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2

I gather you mean, loading a url using .replace() by using a form element:

<form onsubmit="return false">
<input type="button" onclick="location.replace(URLGOESHERE)">
</form>

Danny
On Fri, 15 Jul 2005 10:51:05 -0700, JHB <joern_bea@removeThis_tdcadsl.dk>
wrote:

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by James Marshall | last post: by
9 posts views Thread by Jean Pierre Daviau | last post: by
13 posts views Thread by John Smith | last post: by
5 posts views Thread by Alan Little | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.