By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,370 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

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

syedshaffee
P: 91
i have made a table in asp classic that generates values dynamically.Written 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
Expand|Select|Wrap|Line Numbers
  1.  $(document).ready(function () {    
  2.     //assigning alternative row style
  3. $("#Table_Data tr:even").addClass("evenrow");
  4. $("#Table_Data tr:odd").addClass("oddrow");
  5.  
  6.  $("#Table_Data tr").click(function(){
  7.    $(this).find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
  8.    if($(this).find(':checkbox').attr('checked'))
  9.         {
  10.               var html = '';
  11. $(' #Table_Data td').click(function() {
  12.     html = $(this).text();
  13.     alert(html);
  14.  
  15. });
  16.  
  17.         }
  18.         else
  19.         {
  20.             $(this).removeClass('highlight');
  21.               $(this).addClass('evenrow');
  22.         }
  23. });
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
Jan 20 '12 #1
Share this Question
Share on Google+
2 Replies


P: 62
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:
Expand|Select|Wrap|Line Numbers
  1. r={};
  2. r.length=0;
  3. function clickon(id){ r[id]=1; r.length++; }
  4. function clickoff(id){ delete r[id]; r.length--; }
  5. function printr(r){ var o=""; for(var a in r){ o+=a+","; } o=o.slice(0,-1); return o; }
  6.  
3. I totally don't get this.
Jan 26 '12 #2

syedshaffee
P: 91
ok i will try this thanks for the reply
Jan 26 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.