to save values in an array form a table that is dynamically generated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syedshaffee
    New Member
    • Jan 2012
    • 91

    to save values in an array form a table that is dynamically generated

    i have made a table in asp classic that generates values dynamically.Wri tten a jQuery for retrieving the values from this table by clicking on a checkbox & displaying it in a msgbox i want to save it in an array assuming the customer will select more than one row
    Code:
     $(document).ready(function () {    
        //assigning alternative row style
    $("#Table_Data tr:even").addClass("evenrow");
    $("#Table_Data tr:odd").addClass("oddrow");
        
     $("#Table_Data tr").click(function(){
       $(this).find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
       if($(this).find(':checkbox').attr('checked'))
            {
                  var html = '';
    $(' #Table_Data td').click(function() {
        html = $(this).text();
        alert(html);
        
    });
    
            }
            else
            {
                $(this).removeClass('highlight');
                  $(this).addClass('evenrow');
            }
    });
    My problem is:
    1)array size
    2)only once the value should be save in an array
    3)The back ground of the row doesn't change
  • limweizhong
    New Member
    • Dec 2006
    • 62

    #2
    1. Use [Array].length if you want the length of an array.
    2. Don't use arrays then. Use associative arrays (which all objects are) and ids:
    [code=JavaScript]
    r={};
    r.length=0;
    function clickon(id){ r[id]=1; r.length++; }
    function clickoff(id){ delete r[id]; r.length--; }
    function printr(r){ var o=""; for(var a in r){ o+=a+","; } o=o.slice(0,-1); return o; }
    [/code]
    3. I totally don't get this.

    Comment

    • syedshaffee
      New Member
      • Jan 2012
      • 91

      #3
      ok i will try this thanks for the reply

      Comment

      Working...