HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 13th, 2004, 05:12 PM
prizsm prizsm is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 prizsm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
radio button choices for page redirect

I have three different sets of radio buttons. Depending on the user's selection, a new page opens.

I don't get an error message with this code, but I don't leave my original page either.

(I have active links in my code, but I took them out so no one would think I was advertising.)

Thanks,

Jean

<html>
<head>
<title>More Choices</title>
<script language="JavaScript">
var allOne = new Array ();
allOne[0] = "some link";
allOne[1] = "some link";
allOne[2] = "some link";
allOne[3] = "some link";
allOne[4] = "some link";

var businessOne = new Array ();
businessOne[0] = "some link";
businessOne[1] = "some link";

var masksOne = new Array ();
masksOne[0] = "some link";
masksOne[1] = "some link";
masksOne[2] = "some link";

var allTwo = new Array ();
allTwo[0] = "some link";
allTwo[1] = "some link";
allTwo[2] = "some link";
allTwo[3] = "some link";
allTwo[4] = "some link";

var businessTwo = new Array ();
businessTwo[0] = "some link";
businessTwo[1] = "some link";

var masksTwo = new Array ();
masksTwo[0] = "some link";
masksTwo[1] = "some link";
masksTwo[2] = "some link";

var allThree = new Array ();
allThree[0] = "some link";
allThree[1] = "some link";
allThree[2] = "some link";
allThree[3] = "some link";
allThree[4] = "some link";

var businessThree = new Array ();
businessThree[0] = "some link";
businessThree[1] = "some link";

var masksThree = new Array ();
masksThree[0] = "some link";
masksThree[1] = "some link";
masksThree[2] = "some link";

var levelOne = "(document.adventure.level.one.checked)?true:false";
var levelTwo = "(document.adventure.level.two.checked)?true:false";
var levelThree = "(document.adventure.level.three.checked)?true:fals e";

var shorter = "(document.choose.where.first.checked)?true:false";
var short1 = "(document.choose.where.second.checked)?true:false";
var long1 = "(document.choose.where.third.checked)?true:false";

var nothanks = "(document.list.not.no.checked)?true:false";
var yesplease = "(document.list.not.yes.checked)?true:false";


function whereTo () {
if (levelOne && shorter && nothanks == true) {
window.location = masksOne[Math.floor(Math.random() * masksOne.length)];
}
if (levelOne && short1 && nothanks == true) {
window.location = businessOne[Math.floor(Math.random() * businessOne.length)];
}
if (levelOne && long1 && nothanks == true) {
window.location = allOne[Math.floor(Math.random() * allOne.length)];
}
if (levelTwo && shorter && nothanks == true) {
window.location = masksTwo[Math.floor(Math.random() * masksTwo.length)];
}
if (levelTwo && short1 && nothanks == true) {
window.location = businessTwo[Math.floor(Math.random() * businessTwo.length)];
}
if (levelTwo && long1 && nothanks == true) {
window.location = allTwo[Math.floor(Math.random() * allTwo.length)];
}
if (levelThree && shorter && nothanks == true) {
window.location = masksThree[Math.floor(Math.random() * masksThree.length)];
}
if (levelThree && short1 && nothanks == true) {
window.location = businessThree[Math.floor(Math.random() * businessThree.length)];
}
if (levelThree && long1 && nothanks == true) {
window.location = allThree[Math.floor(Math.random() * allThree.length)];
}
if (levelOne && shorter && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelOne && short1 && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelOne && long1 && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelTwo && shorter && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelTwo && short1 && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelTwo && long1 && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelThree && shorter && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelThree && short1 && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
if (levelThree && long1 && yesplease == true) {
window.location = "http://www.maskwoman.biz";
}
}
</script>
</head>

<body>
<p><h3>Choose a level</h3></p>
<form name="adventure">
<input type="radio" name="level" value="one">First List<br>
<input Type="radio" name="level" value="two">Second List<br>
<input type="radio" name="level" value="three">Third List<br>
</form>
<h3>What do you want to see?</h3>
<form>
<form name ="choose">
<input type="radio" name="where" VALUE="first"> Conduct Business<br>
<input type="radio" name="who" VALUE="second"> Look at Masks<br>
<input type="radio" name="who" value="third"> All
</form>
<h3>Print a list?</h3>
<form>
<form name = "list">
<input type="radio" name="not" VALUE="No"> No<br>
<input type="radio" name="not" VALUE="Yes"> Yes<br>
<input type="button" onclick=" return whereTo()" value="Where?">
</form>
</body>
</html>

Reply With Quote
  #2  
Old February 28th, 2004, 07:11 PM
animweenie animweenie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 29 animweenie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
radio button choices for page redirect

I saw a couple of things you should try to correct the redirection problem:

1) You have extra "form" tags in the Html script above the "choose" form and the "list" form
that have to be removed

2) The names of your elements were not the same for each form block
e.g. name="who" should be change to "where" in the "choose" form

3) When you declare and initialize your variables outside of the whereTo function,
you are referencing the value which contains a string, but you are trying to perform
a boolean comparison below in the function

4) You should evaluate the on/off state of the radio buttons inside of
the whereTo function:

levelOne = document.adventure.level[0].checked;
levelTwo = document.adventure.level[1].checked;
levelThree = document.adventure.level[2].checked;

shorter = document.choose.where[0].checked;
short1 = document.choose.where[1].checked;
long1 = document.choose.where[2].checked;

nothanks = document.list.not[0].checked;
yesplease = document.list.not[1].checked;

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > radio button choices for page redirect


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway