jquery - Javascript multiply 3 inputs -


I know that this topic has been touched many times over here but I can not get it properly. I am pulling a value for #starback which is based on the selected dropdown. Then I want to multiply it by 2 input fields.

Any help is greatly appreciated! thank you in advanced!

  & lt; Input type = "text" id = "resultbox" name = "resultbox" readonly = "true" /> & Lt; Id = "off" onchange = "calc ()" & gt; & Lt; Option value = "1" data-one = "0" & ​​gt; Choose option & lt; / Option & gt; & Lt; Option value = "14" data-one = "14" & gt; Off of & lt; / Options & gt; & Lt; Option value = "8" data-one = "8" & gt; On & lt; / Options & gt; & Lt; / Select & gt; & Lt; Br> & Lt; Br> & Lt ;! - FTE - & gt; FTE & lt; Div id = "f1" & gt; & Lt; Form & gt; & Lt; Input type = "text" name = "FTE" id = "FTE" & gt; & Lt; / Form & gt; & Lt; / Div & gt; & Lt ;! - duration - & gt; Duration & lt; Div id = "d1" & gt; & Lt; Form & gt; & Lt; Input type = "text" name = "duration" id = "duration" & gt; & Lt; / Form & gt; & Lt; / Div & gt; & Lt; Div id = "dom_element" & gt; - & lt; / Div & gt;   

here is javascript

  $ ('# off'). Change (function () {var select1_control = 1; var str = select1_control * $ (this) .find ('option: selected'). Data ('a'); $ ('# resultbox'). Val (str); }); Var multiplier = 1; // Binary Funnel $ ("# FTE"). ("Funnel change", function () {var value = this.value; var valuemath = value * durationMultiplier; $ ("# dom_element"). Text (valuemath);}); $ ('# Period'). Change (function () {duration multiplayer = $ (this) .val (); $ ("# FTE"). Trigger ("key usage");});   

do something like

  function calc (multiply) {if (multiplied) {tt.value = parseFloat (qt.value * un.value) .toFixed (2); } And {un.value = parseFloat (tt.value / qt.value) .toFixed (2); }} & lt; Form & gt; & Lt; Ul & gt; & Lt; Li & gt; Qt: & lt; Input type = "text" id = "qt" onblur = "calc (true)" /> gt; & Lt; / li & gt; & Lt; Li & gt; Unt: & lt; Input type = "text" id = "un" onblur = "calc (true)" /> gt; & Lt; / li & gt; & Lt; Li & gt; Total: & lt; Input type = "text" id = "tt" onblur = "calc (wrong)" /> & Lt; / li & gt; & Lt; / Ul & gt; & Lt; / Form & gt;    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -