Solved

Targeting different pgs from 1 form

Posted on 1998-06-04
11
229 Views
Last Modified: 2010-05-18
My form has 5 radio buttons and I want each of the buttons to take you to a different page in the site whenever  the submit button is pushed. Is this possible ? Please include example if possible, I'm new at this

                                                                       Thank You
                                                                             Big Al
0
Comment
Question by:ablogan
[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
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 6

Expert Comment

by:Holger101497
ID: 1844079
Your question is not 100% clear...
"take you to a different page in the site whenever  the submit button is pushed"... does that mean that you want to go to a "page" or does it mean that you want to change the URL the form submits its data to??
0
 
LVL 8

Expert Comment

by:jhurst
ID: 1844080
I assume that you just want the user to load another page, but the page being selected should be dependant on which button was selected:

In your form, for the button:
<INPUT type=button onClick=doMyForm()>

then you create the function:
function doMyForm()
  { // we arrive here when he presses the submit button
    // we look through the button values with
    if (document.forms......   // see if this is the one checked
        window.location.href='http:// .... // wherever you want to go for this one
  }

Good luck - have fun
   
  }
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1844081
That's what you give as an example because somebody tells you he's new at this??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ablogan
ID: 1844082
Thank You for responding. Yes I'm trying to get different pages loaded in the same web site. There is a particular reason why I'm doing it this way. Please excuse my ignorance but I'm a graphics guy and just learning html.  Here is the code I'm using. I'm not quite sure how to apply what you've just shown me.  In your "do my form"( )..line of code, does the location for the page I want loaded, go in between the brackets. My ' form action' makes every button in the form go to my 'index1.html, wher as I want each one to hit a different page


<form action="index1.html">
<input type="radio" name="individual" value="">Individual<br>
<input type="radio" name="scientist" value="">Scientist<br>
<input type="radio" name="organization" value="">Organization<br>
<input type="radio" name="media" value="">Media<br>
</td><td width="33%" height="33%"></td></tr></table>

<center>
<hr size=5 width=70%>
<input  type="submit" value="send info"><input type="reset">

I hope I'm not confusing you.
Thanks Al

0
 

Author Comment

by:ablogan
ID: 1844083
Holger,
 
Thanks for the interest. Please see my new post. I hope the inclusion of the bit of lousy code and my explaination makes things a little clearer. I don't need this to go to another server or anything.

Thanks Al
0
 

Author Comment

by:ablogan
ID: 1844084
I have to leave now, I'll be back on 2 morrow. Thanks Guys
Big Al
0
 
LVL 5

Accepted Solution

by:
Christian_Wenz earned 50 total points
ID: 1844085
Hi ablogan, try this:

a) give each of these radio buttons the same name attribute (name="something") so that the user can only select one of them.
b) now put the following in the <HEAD> part of your page:
<SCRIPT LANGUAGE="JavaScript"><!--
function doit(){
  if (document.forms[0].elements[0].checked) then location.href="individual.html"
  if (document.forms[0].elements[1].checked) then location.href="scientist.html"
  if (document.forms[0].elements[2].checked) then location.href="organization.html"
  if (document.forms[0].elements[3].checked) then location.href="media.html"
}
//--></SCRIPT>

c) remove the ACTION="index1.html" from your form tag
d) instead of <input type=submit value="send info">, use
<input type="button" value="send info" onClick="doit()">

if there is something unclear, please leave a comment.
0
 

Author Comment

by:ablogan
ID: 1844086
Hello Christian,

Thank you for your java code. Something isn't working right though, so maybe you could tell me what I'm doing wrong. Here is my code for the page,

<html><head><Title>Submit Page</title>
   <SCRIPT LANGUAGE="JavaScript"><!--  
   function doit(){
     if (document.forms[0].elements[0].checked) then location.href="typeform.html"
     if (document.forms[0].elements[1].checked) then location.href="scientist.html"
     if (document.forms[0].elements[2].checked) then location.href="organization.html"
     if (document.forms[0].elements[3].checked) then location.href="media.html"
     if (document.forms[0].elements[4].checked) then location.href="Country.html"
   }
   //--></SCRIPT>

  </head>

<body>
<body background="blue col.gif">
<center>
<img src="senda.gif">
<hr size=5 width=70%>
<h2>Please Select One of The Following</h2>
</center>

<table><tr>
<td width="33%" height="33%"></td>
<td width="34%" height="33%">

<form>
 <input type="radio" value="send info" onClick="doit()">Individual<br>
 <input type="radio" value="send info" onClick="doit()">Scientist<br>
 <input type="radio" value="send info" onClick="doit()">Organization<br>  
 <input type="radio" value="send info" onClick="doit()">Media<br>
 <input type="radio" value="send info" onClick="doit()">Country<br>  
</td><td width="33%" height="33%"></td></tr></table>></form>

<center>
<hr size=5 width=70%>
<br><br

</body>
</html>
 
Thanks, Al






0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1844087
This is not my question and it's locked, but here's a hint:

Some HTML for beginners *g*:
1) JavaScript doesn't know THEN... it should be if (condition) statement;
=> just delete the "then"'s
2) Don't use 2 <BODY> tags
3) Don't open the form IN the table and close it outside... proper nesting shows you that you should close the form before you close the table cell that contains it
4) Close your <BR at the end :-))
5) Lastly and most inportantly: Your radio buttons need a name (Christian mentioned it) - all the same one. Just add "name=choosedest" to each one

That should actually do it.
Not all of the above are a problem for Netscape 4, but they might be for other browsers... and you just shouldn't upload bad HTML...

Good luck!

0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1844088
Of course Holger's right about the THEN; when I wrote this, I just came from programming in another language for some hours :-(

0
 

Author Comment

by:ablogan
ID: 1844089
Thanks for the help. It now works
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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)

688 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