Submit Button

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?
LVL 12
Nathan RileyFounderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

<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.
Nathan RileyFounderAuthor Commented:
<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?
Nathan RileyFounderAuthor Commented:
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?
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

<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.
Nathan RileyFounderAuthor Commented:
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">
        <legend>More Information? </legend>
        <label for="name">your name </label>
        <input onfocus="" 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="" 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="" 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="" 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>

Open in new window

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, and I code in ASP - but they're similar animals, and this should work for you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nathan RileyFounderAuthor Commented:
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?
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")


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 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.
Oops, my bad on the code -

Response.Redirect("favmag1") should be

Nathan RileyFounderAuthor Commented:
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:
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. is a little different, so if it doesn't work, I can't steer you in that regard.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.