Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

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?
Avatar of BurtAnderson
BurtAnderson
Flag of United States of America image

<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.
Avatar of Nathan Riley

ASKER

<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?
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?
<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.
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

ASKER CERTIFIED SOLUTION
Avatar of BurtAnderson
BurtAnderson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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")

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

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


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:

https://www.experts-exchange.com/questions/23919202/Trust-Level-Issues.html

https://www.experts-exchange.com/questions/23918648/Assembly-does-not-allow-partially-trusted-callers.html
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.