4
I created a form that is added to the page through a button. I used JS to create the form to be added. The problem is that I have two fields one of value and the other of hours, to account for the value of the hour worked. Then I applied the input that receives the value and time given to the function:
onblur="value();".
Valor:
input name="horas" id="horas" type="text" value="" onblur="value();" class="form-control"
Time:
input name="valor" id="valor" type="text" value="" onblur="value();" class="form-control
This value function is as follows::
function value(){
var val= $("input[name*='valor]']").maskMoney('unmasked')[0];
var hs= Number($("input[name*='horas']").val());
var resul= (hours == 0 ? 0 : val/hs);
$('#resulVal').val(resulVal.toFixed(2).replace('.', ','));
}
When I add only ONE FORM, the function performs the account. But when adding more than one form the following do not account, it is as if the function was not activated for the others. What to do?
When you say "don’t realize the account", do you make a mistake? or just don’t show up what you wanted?
– PauloHDSousa
I believe it must have something to do with
name
or theid
of the element– MarceloBoni
Friend, this "a form", you added it by manipulating the DOM with javascript too ? If you make an example in Jsfiddle it is easier for us to help. But one thing that can happen is in relation to the formularies for being added dynamically. Before in Jquery there was a function called $.live that treated events in dynamic elements, today there is another way to treat these events.
– Silvio Lucena Junior