Solved

Javascript submission of form with redirect

Posted on 2008-09-30
3
771 Views
Last Modified: 2012-05-05
Should be a fairly easy question, but cannot find anything to work!

I have a simple form on an ASP page that submits to itself with a submit button. Once posted, the ASP code collects the posted data, saves to a DB and then redirects to the next page.

I would also like to place another button on the page that once clicked - will submit the form and then redirect to another page. (a save and logout button)

I figure the only way to do this would be with javascript i.e. javascript: document.forms.formname.submit(); window.location = 'page.asp'; but this is not working...any ideas?
0
Comment
Question by:markm5i
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
nkoriginal earned 500 total points
ID: 22611810
Try this...
Check the page name.
To redirect any page in asp you need to use, response.redirect("")
You can call result.asp and put the redirect there, is up to you
Let me know if you need something else

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<html>
<head>
<title>Untitled Document</title>
</head>

<body>

<%
if request.Form("submit") = "submit" then

' code to insert in DB

response.Redirect("show.html")

end if
%>

<form action="result.asp" method="get">
<input type=text name=xxx>
<input name="submit" type=submit value="submit">
</form>
</body>
</html>
0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22612701
You can do this with javascript if you submit the form to a small iframe on the page.
Beware you will have no feedback if save fails.

Somthing like this:

<form id="myForm" name="myForm" action="save.asp" target="_top" method="post">
<input type="submit" value="save">
<input type="button" value="save & logout" onClick="JavaScript:document.getElementById('myForm').target='saveFrame';document.getElementById('myForm').submit();window.location.href='logoutpage.asp'">
</form>
<iframe width=1 height=1 src="blank.html" id="saveframe" name="saveframe">

Open in new window

0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22612710
Setting additonal parameters in the iframe tag hides it more:
border=0 frameborder=0 scrollbars=0
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question