Question

Why doesn't this work ?? :(

Asked by: Ninibini

I'm trying to make a trivia page for a website ...
take a look at
http://www.geocities.com/bbstory/test/trivia.htm
to see what I've got so far...

Getting the info from the radiobuttons works fine, also which items of the left comboboxs are selected ...

but when I'm trying to get the selected items of the right comboboxes, using "exactly" the same code as for the left, I get wrong results (See alerts on website).

so here's my JavaScript code:

<script language="JavaScript">
<!-- Begin
function button1_onclick()                              //Hauptfunktion, die die Eingaben auswertet
{
      var array_Radio = new Array(4);            //selected radiobutton
      var array_Solution_Radio = new Array("1","2","3","2","1"); //trivia solutions
      
      var array_combo1 = new Array(4);      //selected item - left combo
      var array_combo2 = new Array(4);      //selected item - right combo
      
      var array_Solution_Book = new Array("hm","hm","hm","hm","hm"); //trivia solution left combo
      var array_Solution_Character = new Array("1","2","3","2","1"); //trivia solution right combo
      
      var points=0;
      var tmp;
      var test="";      //just for debugging
      
      //getting results for radiobuttons
      for (x=0;x<5;x++)
      {
            tmp='radio'+(x+1);
            array_Radio[x]=getRadioValue(tmp);
            
            if (array_Radio[x]==array_Solution_Radio[x])
            {
                  points=points+10;
            }
      }
      
      //get combobox value
      
      array_combo1[0]=select1.options[select1.selectedIndex].value;
      array_combo1[1]=select3.options[select3.selectedIndex].value;
      array_combo1[2]=select5.options[select5.selectedIndex].value;
      array_combo1[3]=select7.options[select7.selectedIndex].value;
      array_combo1[4]=select9.options[select9.selectedIndex].value;
      
      //debugging, which items of the left comboboxes are selected      
      for (x=0;x<5;x++)            
      {test=test + array_combo1[x] + " "}            
      alert(test);
      



      
//?????????????????????????????????????????????????????
      
//trying to do the same as above for the right comboboxes
//HELP - why doesn't these lines work?      

                  
      array_combo2[0]=select2.options[select2.selectedIndex].value;
      array_combo2[1]=select4.options[select4.selectedIndex].value;
      array_combo2[2]=select6.options[select6.selectedIndex].value;
      array_combo2[3]=select8.options[select8.selectedIndex].value;
      array_combo2[4]=select10.options[select10.selectedIndex].value;
      
      test="";      
      for (x=0;x<5;x++)            
      {test=test + array_combo2[x] + " "}      //I should get the values here !!!!      
      alert(test);

//????????????????????????????????????????????????????????

      /* //comparing solution with selected items
      for (x=0;x<5;x++)
      {
            alert("aussen: " + array_combo1[x] + " - " + array_Solution_Book[x]);

            if (array_combo1[x]==array_Solution_Book[x])
            {
                  alert("innen: " + array_combo2[x] + " - " + array_Solution_Character[x]);
                              
                  if (array_combo2[x]==array_Solution_Character[x])
                  {
                        points=points+10;
                  }            
            }
      }*/
      
      alert("You've reached " + points + " points");
}

//---------------------------------------------------------      
function getRadioValue(RadioName)            //Aufruf: getRadioValue('radio1')
{
  var collection;
  collection = document.all(RadioName);

  for (j=0;j<3;j++)
  {
    if (collection[j].checked)
    {
                  return [collection[j].value];            //returns selected item
            }
  }
}

//---------------------------------------------------------
function RemoveItems(id)                        //remooves items from combobox
{
      while(id.length!=0)
      {
            id.remove(0);
      }
}

//---------------------------------------------------------
function AddItem(id,str,i)                        //adds new item to combobox
{                                                                        //id:  combobox
      var oOption = document.createElement("OPTION");      //str: text of new item
      id.options.add(oOption);      //i:   value of new item
      oOption.innerText = str;
      oOption.Value = i;
      if(i=="0")
      {
            oOption.selected=true;
      }
}

//---------------------------------------------------------
function create_list(id,val)
{
      RemoveItems(id);
      switch (val)
      {
            case "n/a": AddItem(id,"<not given>",'asdfasdf');
                                    break;
            case "hs":  AddItem(id,"Susannah Faulconer",'a');
                                    AddItem(id,"Sam Gamble","v");
                                    AddItem(id,"Mitchell Blaine","2");
                                    AddItem(id,"Yank Yankowski","3");
                                    AddItem(id,"Paige Faulconer","4");
                                    AddItem(id,"Calvin Theroux ","5");
                                    AddItem(id,"Joel Faulconer","6");
                                    AddItem(id,"Sam & Susannah","7");
                                    AddItem(id,"Mitch & Susannah","8");
                                    break;
            case "hm":      AddItem(id,"Honey Moon",0);
                                    AddItem(id,"Dash Coogan",1);
                                    AddItem(id,"Eric Dillon",2);
                                    AddItem(id,"Liz Castleberry",3);
                                    AddItem(id,"Chantal Booker",4);
                                    AddItem(id,"Dash & Honey",5);
                                    AddItem(id,"Eric & Honey",6);
                                    AddItem(id,"Honey & Liz",7);
                                    break;
            case "fp":      AddItem(id,"Francesca Day",0);
                                    AddItem(id,"Dallie Beaudine",1);
                                    AddItem(id,"Ted Baudine",2);
                                    AddItem(id,"Skeet Cooper",3);
                                    AddItem(id,"Holly Grace Baudine",4);
                                    AddItem(id,"Dallie & Francesca",5);
                                    AddItem(id,"Dallie & Skeet",6);
                                    AddItem(id,"Dallie & Holly Grace",7);
                                    AddItem(id,"Skeet & Francesca",8);
                                    break;
            case "kaa":      AddItem(id,"Daisy Deveraux",0);
                                    AddItem(id,"Alex Markov",1);
                                    AddItem(id,"Heather Pepper",2);
                                    AddItem(id,"Sheba Quest",3);
                                    AddItem(id,"Max Petrov",4);
                                    AddItem(id,"Brady Pepper",5);
                                    AddItem(id,"Alex & Daisy",6);
                                    break;
            case "ihtby":AddItem(id,"Phoebe Sommerville",0);
                                    AddItem(id,"Dan Calebow",1);
                                    AddItem(id,"Molly Sommerville",2);
                                    AddItem(id,"Ron McDermit",3);
                                    AddItem(id,"Bobby Tom Denton",4);
                                    AddItem(id,"Viktor Szabo",5);
                                    AddItem(id,"Dan & Phoebe",6);
                                    AddItem(id,"Dan & Ron",7);
                                    AddItem(id,"Phoebe & Ron",8);
                                    break;
            case "ht":      AddItem(id,"Bobby Tom Denton",0);
                                    AddItem(id,"Gracie Snow",1);
                                    AddItem(id,"Suzy Denton",2);
                                    AddItem(id,"Way Sawyer",3);
                                    AddItem(id,"Bobby Tom & Gracie Snow",4);
                                    AddItem(id,"Way Sawyer & Suzy Denton",5);
                                    break;
            case "nbbm":AddItem(id,"Jane Darlington",0);
                                    AddItem(id,"Cal Bonner",1);
                                    AddItem(id,"Annie Glide",2);
                                    AddItem(id,"Ethan Bonner",3);
                                    AddItem(id,"Kevin Tucker",4);
                                    AddItem(id,"Lynn Bonner ",5);
                                    AddItem(id,"Jim Bonner",6);
                                    AddItem(id,"Jodie Pulanski",7);
                                    AddItem(id,"Cal & Jane",8);
                                    AddItem(id,"Kevin & Jane",9);
                                    break;
            case "dald":AddItem(id,"Rachel Stone",0);
                                    AddItem(id,"Gabe Bonner",1);
                                    AddItem(id,"Edward Stone",2);
                                    AddItem(id,"Kristy Brown",3);
                                    AddItem(id,"Ethan Bonner",4);
                                    AddItem(id,"Jane Darlington ",5);
                                    AddItem(id,"Cal Bonner",6);
                                    AddItem(id,"Gabe & Rachel",7);
                                    AddItem(id,"Ethan & Kristy",8);
                                    break;
            case "lbg":      AddItem(id,"Lady Emma Wells-Finch ",0);
                                    AddItem(id,"Kenny Traveler",1);
                                    AddItem(id,"Torie Traveller  ",2);
                                    AddItem(id,"Ted Baudine ",3);
                                    AddItem(id,"Dexter O'Conner",4);
                                    AddItem(id,"Shelby Traveller",5);
                                    AddItem(id,"Warren Traveller",6);
                                    AddItem(id,"Hugh Duke of Beddington",7);
                                    AddItem(id,"Kenny & Emma",8);
                                    break;
            case "fl":      AddItem(id,"Nealy Litchfield Case",0);
                                    AddItem(id,"Mat Jorik",1);
                                    AddItem(id,"Lucy Jorik",2);
                                    AddItem(id,"Bertis Wayne",3);
                                    AddItem(id,"Charlie Wayne",4);
                                    AddItem(id,"Jason Williams",5);
                                    AddItem(id,"Toni DeLuca",6);
                                    AddItem(id,"Mat & Nealy",7);
                                    AddItem(id,"Mat & Lucy",8);
                                    break;
            default:            break;
      }
}

// End -->
</script>


I really would appreciate you help, cause I totally stuck right now.

Thanks, Nina

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2000-06-30 at 03:14:39ID10576661
Tags

combobox

Topic

JavaScript

Participating Experts
2
Points
200
Comments
6

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Using CGI with FP extensions.
    Hello fellow experts. Here is the situation. I have a client who wants the ability to make minor changes, (yea, I know, but...). This client is stuck on being able to use Front page to open the page and just save it. (By "opening a Front Page web) Now, for the tough...
  2. I CANNOT get MS Word Material to Work in FP
    I simply cannot get material created in Word to work in FP. Before getting FP I had never used Word. Because of all the hype about the great interoperability I sprung for Office 2000 and began trying to move material created in Word into FP. I concluded it can't be done...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: NinibiniPosted on 2000-06-30 at 03:20:33ID: 3136169

Adjusted points from 100 to 200

 

by: CJ_SPosted on 2000-06-30 at 04:27:58ID: 3136659

I think it's partly due to this function:

function AddItem(id,str,i)                        //fügt eine neues item in eine combobox hinzu
{                                                                                                                                                                  //id:  combobox
      var oOption = document.createElement("OPTION");                  //str: neuer Eintrag
      id.options.add(oOption);                                                                                    //i:   value des neuen Eintrags
      oOption.innerText = str;
      oOption.Value = i;
      if(i=="0")
      {
            oOption.selected=true;
      }
}

try this:

function AddItem(id,str,i)                        //fügt eine neues item in eine combobox hinzu
{                                                                                                                                                                  //id:  combobox
      var oOption = document.createElement("OPTION");                  //str: neuer Eintrag
      id.options.add(oOption);                                                                                    //i:   value des neuen Eintrags
      oOption.text = str;
      oOption.value = i;
      if(i==0)
      {
            oOption.selected=true;
      }
}

 

by: mplungjanPosted on 2000-06-30 at 04:33:36ID: 3136725

An none of this will run in Netscape...

Michel

 

by: NinibiniPosted on 2000-06-30 at 04:40:05ID: 3136761

Comment accepted as answer

 

by: NinibiniPosted on 2000-06-30 at 04:40:06ID: 3136762

You're great!

I can't believe it was just because value was typed with a capital letter ...

Thanx

 

by: CJ_SPosted on 2000-06-30 at 04:43:29ID: 3136775

AND that you had quotes around the 0

Ur welcome!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...