[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Submit Button

Posted on 2008-11-19
11
Medium Priority
?
258 Views
Last Modified: 2013-11-17
After I hit my submit button that submits my form it takes me to the same page with all the info in the address bar.  That part is all fine except I want it to take me to a different page instead of the same one when I hit the button is there an easy fix?
0
Comment
Question by:Nathan Riley
  • 6
  • 5
11 Comments
 
LVL 7

Expert Comment

by:BurtAnderson
ID: 22997028
<form name="whatever" action="What page is listed here?">

I'd suggest the issue is with the form tag, not the submit button. Make sure it's pointed to the right page and you should be golden.
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 22997113
<form action="#" which I can change to the next page I want?  Will It still display the items in the address  bar from the form?
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 22997128
Ok tested works perfectly, thanks.  One last question and I can open another so you can get points, but wanted to reference this one.  In the form I have a drop down box and depending on what the person selects from that box will determine where they are forwarded when hitting submit, how can I accomplish that?
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 7

Expert Comment

by:BurtAnderson
ID: 22997895
<select name="whatever-name-you-want"> - the name is the variable you're passing from your form. Whichever <option> they select will populate that variable.

In the <form> tag, you have a method, so it would look something like this:

<form name="name" action="action.asp" method="post">

There are 2 methods, "post" and "get". "Post" will send hidden data, "get" includes it in the URL. "Get" is the default, which is why it's working the way you want.

You'll have the form's "action" page grab the variable from the <select> tag, and run a redirect to the desired page from there.
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 22997930
I see similar code but not exactly the same.  The options I want to determine from are from the Select your favorite interest values
 <form action="technology.aspx" method="get" id="signup" title="Sign up to our mailing list" dir="ltr" xml:lang="en">
        <fieldset>
        <legend>More Information? </legend>
        <label for="name">your name </label>
        <input onfocus="this.select()" onblur="if (this.value==''){this.value='enter your name'}" name="name" id="name" type="text" value="enter your name" size="20" />
        <label for="email">your phone</label>
        <input onfocus="this.select()" onblur="if (this.value==''){this.value='enter your phone #'}" name="phone" id="phone" type="text"  value="enter your phone #" size="20" />
        <label for="email">your email</label>
        <input onfocus="this.select()" onblur="if (this.value==''){this.value='enter your email address'}" name="email" id="email" type="text"  value="enter your email address" size="20" />
        <label for="postalcode">postal code </label>
        <input onfocus="this.select()" onblur="if (this.value==''){this.value='enter your postal code'}" name="postalcode" id="postalcode" value="enter your postal code" size="20" />
        <label for="favmag1">Select your favorite interest </label>
		<select id="favmag1" name="favmag1" >
		  <option value="0">- - Select your favorite interest - -</option>
		  <option value="1">Health &amp; Wellness</option>
          <option value="2">Technology</option>
          <option value="3">Travel</option>
          <option value="5">Financial Services</option>
          <option value="4">Internet Advertising</option>
          <option value="6">Gas &amp; Utilities</option>
        </select>
        <fieldset>

Open in new window

0
 
LVL 7

Accepted Solution

by:
BurtAnderson earned 2000 total points
ID: 22998028
Your <select> and <option> information looks good, no problems there. "technology.aspx" is your action page, so all values from the form will be passed there. That page will handle the redirect to whichever page you want.

Give your form a name, for starters.

<form name="myform" action="technology.aspx" method="get" id="signup" title="Sign up to our mailing list" dir="ltr" xml:lang="en">

Then on technology.aspx, make sure Response.Buffer="true" (it's true by default nowadays, so probably no problems there)

dim myVariable (to declare your variable)

myVariable = Request.QueryString("favmag1")

Then it's just if/then statements.

if favmag1 = 0 then Response.Redirect("whatever page you want to send them to") end if

It looks like you're using ASP.net, and I code in ASP - but they're similar animals, and this should work for you.
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 22998094
Ok thanks again.  Index.aspx is where the form is and technology.aspx is just an example I had in there for it to go to.  Technology.aspx is an option of one of the pages it should go to if the right option is chosen so should I create a dummy.aspx page to put my if/thens on?  And if so will I still be able to have my stored procedure insert the values on the dummy page or will it only redirect?
0
 
LVL 7

Expert Comment

by:BurtAnderson
ID: 22998299
You may be able to simplify matters in the <option> tags.

On index.aspx, for example, instead of having <option value="0"> and then running if/then statements on the processing page, you can say <option value="technology.aspx">. Then on the processing page, you'd just plug that value into the redirect.

dim myVariable (to declare your variable)

myVariable = Request.QueryString("favmag1")

Response.Redirect("favmag1")

It may save some headache that way, or cause new ones. Code can be funny like that!

The processing page can do whatever you want with the data you've collected. It might send an email to you with some of the information - my sites email me all the time. It might save information in a database. The main thing is, you'll need a processing page with a redirect to operate a select menu the way you want. Unless ASP.net has some nifty feature I don't know about, you can't redirect from there, since the page is already rendered and sent to the client. You've got to get them back to your server so you can work your behind-the-scenes magic.

Javascript might be able to let them bounce around from the index page without submitting data for processing, but I don't use enough of it to tell you how - I'd have to research it myself.
0
 
LVL 7

Expert Comment

by:BurtAnderson
ID: 22998315
Oops, my bad on the code -

Response.Redirect("favmag1") should be
Response.Redirect("myVariable")


0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 22998418
Perfect thanks.  Now if only I could test lol.  I don't want to keep asking you questions without you getting more points here are 2 other ways I've tried fixing my trust issues so I can see if the code even works.  If you know something help would be great, otherwise thanks for your help so far:

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23919202.html

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23918648.html
0
 
LVL 7

Expert Comment

by:BurtAnderson
ID: 22998544
Points are fun, but I think everyone is here just to help each other out.

As for testing the code, you can either send it to a hidden directory on your webserver to test it, or test locally if you have IIS (Internet Information Services) turned on. There's a primitive version built into XP - if you're on Vista, I would think there's one there as well.

Turn on IIS at control panel > add/remove programs > add/remove Windows components > check the box for IIS.

At least, that works fine for ASP. ASP.net is a little different, so if it doesn't work, I can't steer you in that regard.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

865 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