On 8/31/06, Maram <[EMAIL PROTECTED]> wrote:
> I newbie in javascript... you have same code... for that...?
I'm going to give you pseudo-javascript because I can't remember the
TG widget naming conventions and I'm too lazy to look them up. :]
Let's say your form has an id of 'myform' and your fields are named
'field1','field2', and 'sum'.
Your javascript file will look something like:
var sumfields = function(){
var myform = $('myform'); //getElementById('myform')
var field1val = parseInt(myform.field1.value) || 0; //if parseInt
fails, set value to 0
var field2val = parseInt(myform.field2.value) || 0;
myform.sum.value = field1val + field2val;
}
//initialize page
connect(window,'onload', function(){
var myform = $('myform');
connect(myform.field1, 'onchange', sumfields);
connect(myform.field1, 'onchange', sumfields);
});
You can ensure MochiKit is on the page by adding the MochiKit widget
to the page and if you want a clean way to integrate and reuse your
js, take a look at JSSource.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---