[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Dreamweaver Radio Button Validation Question

Posted on 2006-11-29
2
Medium Priority
?
461 Views
Last Modified: 2010-08-05
I am working on a form where the user has to select one of two button on 27 different items.  I keep get a debug error on my JavaScript and I can't figure out what I'm missing.  Here is my code (I have commented out some lines in the middle when the first variable value would not pass).  HELP (if possible):

//JavaScript Document
function frmValidate(rdo1, rdo2, frm)

      //beginning of how to alert user with two line breaks at end for a double space
      
      var errAlert = "The Following are required:\n\n";
      
      // counter to let you know how man errors exist...no alert if no error present
      
      var errCt = 0;
      
      for (var i=0; i< 4; i++)
      {
            if (frm(rdo1)[i].checked)
            {
                  errAlert = ""
                  errCt = 0;
                  break;
                  
            }
            else
            {
                  //if there is an error, let's add one to the count
                  errCt = errCt +1;
            }
      }
      
      if (errCt > 0)
      {
            errAlert = errAlert + "-- Question 1" + "\n"
      }
      
      /*errCt = 0
      for (var j=0; j<=3; j++)
      {
            if (document.getElementByID(rdo2).checked ==true)
            {
                  errAlert = ""
                  errCt = 0;
                  
                  return true;
                  break;
            }
            else
            {
                  //if there is an error, let's add one to the count
                  errCt = errCt +1;
            }
      }
      if (errCt > 0)
      {
            errAlert = errAlert + " -- Question 2" + "\n"
      }
      */
      
            if (errCt > 0)
            {
                  //if the error count is greater than zero, then let's alert the user of what he/she missed.
                  alert(errAlert);
                  return false;
            }
            
            return true;
      }
0
Comment
Question by:cyndylove46
[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
2 Comments
 
LVL 17

Accepted Solution

by:
NicksonKoh earned 750 total points
ID: 18042583
Hi cyndylove46,

what's rdo1, rdo2, frm? and I am confused by frm(rdo1)[i]?? U got checkboxes?

If they are, I would change this to

for (var i=0; i< 4; i++)
     {
          if (frm(rdo1)[i].checked)

for (var i=0; i<frm.chkbox.length; i++) {
    if (frm.chkbox[i].checked)
    ....


Cheers
Nickson
0
 

Author Comment

by:cyndylove46
ID: 18042724
Thank you for asking.  This code is a bit convoluted since we (my pro friend and I) started.  

The rdo1, rdo2 was supposed to be the variables for radio button selection.  That didn't work, and we started looking at checked boxes.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

656 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