Re: Calculated field in form application
Sorry, this doesn’t work, since I have an editable grid with several rows, in which the fields have names “punkte1”, “punkte2”, “punkte3”, …, “bonus1”, “bonus2”, “bonus3”, …
Meanwhile I use the following code:
// form onLoad event:
document.F1.focusedFormElement = null;
var n = function() {
document.F1.focusedFormElement = this.form.focusedElement = this;
},
p = function() {
document.F1.focusedFormElement = this.form.focusedElement = null;
};
document.F1.focusedElement = null;
for(var j = 0, e = document.F1.elements; j < e.length; ++j) {
e[j].onfocus = n;
e[j].onblur = p;
}
document.F1.sumPunkte = function(row) {
var punkteSelector = 'input[name=punkte'+row+']';
var bonusSelector = 'input[name=bonus'+row+']';
var gesamtSelector = 'input[name=gesamt'+row+']';
jQuery(gesamtSelector).val(parseInt(jQuery(punkteSelector).val().replace(/./g, "")) + parseInt(jQuery(bonusSelector).val().replace(/./g, "")));
}
// inputs field's onChange event:
var row = document.F1.focusedFormElement.id.substr(document.F1.focusedFormElement.id.length-1,1);
document.F1.sumPunkte(row);
This code is working fine, if I update existing records.
But if I click the “New” button to insert a record, a new row in the form is created, where the above code is not bound to the newly created input fields.
I need some event to be fired, when the “New” button is clicked, to bind the JS code at that moment to the newly created input fields.
How can I do this???