0
Galera I have a form with several input that follow a sequence of pair, ie: value1 for cost1, value2 for cost2 and etc...
I need to take the value of the input value1 and assign the same value to the cost1.
But I have several inputs and think about creating a script where I will do the attribution, and in each input I call the event and inform the name of the input, the script goes and assigns the value in the desired input.
The problem is that I don’t know how to do this, can anyone help me?
<input type='text' id='valor1' name='valor1'>
<input type='text' id='custo1' name='custo1'>
<br>
<br>
<input type='text' id='valor2' name='valor2'>
<input type='text' id='custo2' name='custo2'>
thank you very much for the help, it worked perfectly
– Hugo Borges
well I have one more question, without wanting to abuse more you can help me? I created an input called cost, where I will inform a value, then I have the inputs called value and margin, where I will enter a value in the margin in % and it will fill the value based on cost. Could you help me? Follow the code: https://jsfiddle.net/7aq46h0x/2/
– Hugo Borges
What would be the calculation?
– Joao Paulo
ok, it would be like this: I would inform the cost, right after I would inform a % in the margin field, the java has to take the cost see what the updated value based on the profit margin and put in the corresponding value field. Example of the java calculation: {var valor_magem = Math.round(cost * margin) / 100; var new_value = cost + value_act;}
– Hugo Borges
See if that’s it: https://jsfiddle.net/7aq46h0x/5/
– Joao Paulo
that’s right :) friend got very good. Just one more thing, is it possible to do the reverse tbm? type if I inform a value it tells me what profit margin obtained. has as?
– Hugo Borges
You do. https://jsfiddle.net/7aq46h0x/6/
– Joao Paulo
Let’s go continue this discussion in chat.
– Hugo Borges
cool, but what I wanted to know is if there’s any way to keep the two forms together, that is at the same time. if I inform the margin it generates the value, if I inform the value it generates the margin. This is possible?
– Hugo Borges
Yes, just merge the last two fiddles. https://jsfiddle.net/7aq46h0x/7/
– Joao Paulo
friend, got very good. code got very simple. Thanks and congratulations.
– Hugo Borges
just one more hahaha doubt. I’m trying to make him write the value in the en standard, ie: 400.33. I tried the following: {inputValor = inputValor.toString(). replace('.', ',');} but it didn’t work out, have any idea how to do it?
– Hugo Borges
https://jsfiddle.net/7aq46h0x/8/
– Joao Paulo
perfect, worked 100%
– Hugo Borges
Could you give me a hand with this problem here? http://answall.com/questions/115916/problema-ao-formatter-numbers-com-javascript
– Hugo Borges
hello without wanting to abuse, I could use a hand with this question here: http://answall.com/questions/116529/como-resolve-problema-de-calciulo-de-margem-javascript
– Hugo Borges