SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Sheffield
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Setting a values based on a variable control name.

    I have a table in which each row includes a radio button group. I want to keep visible counts of how many of the radio buttons in each column are selected. I have never used JavaScript before and don't really know what i'm doing. I've generated a function that I point to in the onChange attribute of each radio button, which is supposed to count the selected radio buttons in each column and update the visible count. Here's my code, I've placed questions at the places I'm not sure about:
    PHP Code:
    function allocationCount() {

      
    //Array values generated by PHP
      
    var ucards = new Array("T63020015","023565445","T41940023");
      var 
    classIDs = new Array("Array","class99","436","345","dfh");
      var 
    counts = new Array(0,0,0,0,0);
      
      
    //Iterate over rows
      
    for (var u=0u<ucards.lengthu++)
      {    
        
    //Iterate over columns
        
    for (var c=oc<classIDs && !checkedClassc++)
        {
          if (eval(
    "document.allocationTable."+ucards[u]+"[c].checked"))  //Is this array notation the correct way to identify a particular radio button in a group?
          
    {
            
    counts[c]++;
          }
        }
      }

      
    //Iterate over the columns updateing the visible counts  
      
    for (var c=oc<classIDs.lengthc++)
      {
        eval(
    "document.allocationTable."+classIDs[c]+"Count.value) = counts[c];  
        //How does one point to a control based on a variable?
      }


    Any help would be appreciated!!

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Sheffield
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have cleared up some issues and now have this problem:
    The line 'if (eval("document.allocationTable."+ucards[u]+"["+c+"].checked"))' is killing the execution. Any ideas why this would be?
    Last edited by N51; Feb 21, 2005 at 09:50. Reason: Made alteration but problem remains

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Sheffield
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved, a value in ucard started with a numberical character.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •