[Proto-Scripty] Re: Get value from table cell when table row have checkbox checked

2008-09-12 Thread ColinFine



On Sep 12, 5:10 am, Daniel Lopes [EMAIL PROTECTED] wrote:
 Thanks Diogo... this fix my problem:

 function check_entries(){
         sum = 0;
         $$(#entries_list input:checked).each( function(e) {
                 value = $(value_+$(e).id).innerHTML;
                 value = currency_to_float(value);
                 sum += parseFloat(value);
          });
         alert(sum);

 }

 function currency_to_float(value){
         value = value.gsub(/[R$.)]/, '') ;
         value = value.gsub(/,/, '.');
         value = value.gsub(/(/,'-');
         return value

 }


An approach I have used is something like

$$(#entries_list input:checked).each( function(e) {
   var value = e.up('tr').down('.value').firstChild.value;

Since you are using their position in the DOM tree, you don't have to
worry about setting the right id on the value TD's.

Colin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Get value from table cell when table row have checkbox checked

2008-09-12 Thread RobG



On Sep 12, 12:53 pm, Daniel Lopes [EMAIL PROTECTED] wrote:
 This not solution when you want use grids... table are not for layout,
 right use is to display data, layout must be maded in divs.

That makes no sense at all.  I wasn't suggesting your use of a table
is wrong, but that you use the form controls the way they were meant
to be used, i.e. in a form.

--
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Get value from table cell when table row have checkbox checked

2008-09-11 Thread Diogo Neves
Hi,
I think the easiest method is add an id in your td with value,

then do a
$$(.entries_list input:checked).each( function( elem ) {
  valor = $('value_' + $(elem).id).innerHTML;
  // Do stuff with it :P
});

On Thu, Sep 11, 2008 at 10:12 PM, Daniel Lopes [EMAIL PROTECTED]wrote:


 Hello, i'm trying create function that sum the content of td when
 other td in same tr has checkbox checked... i try use someting like $$
 (.entries_list input:checked) but return only input and not row or
 cell i want sum.


 table width=100%
  tr class=credit
tdinput id=entry_2 name=entry_2 type=checkbox
 value=1 //td
td class=desc Pagamento 2ª parcela Inpacto
 Produções/td
td class=category /td
td class=value id=value_entry_2850,00/td
tda href=/accounts/2/entries/2Exibir/a/td
tda href=/accounts/2/entries/2/editEditar/a/td
  /tr
  tr class=debit category_2
tdinput id=entry_3 name=entry_3 type=checkbox
 value=1 //td
td class=desc Pagamento/td
td class=category retirada/td
td class=value id=value_entry_3-20,00/td
tda href=/accounts/2/entries/3Exibir/a/td
tda href=/accounts/2/entries/3/editEditar/a/td
  /tr
/table

 I just want sum value cell when checkbox's on the same line is
 checked.

 Someone can help?
 Many thanks.

 

-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---