I have a problem by returning the values of two functions and adding them together, I have to add the fruit number to the kernel
HTML
& lt; Select class = "fruit" & gt; & Lt; Option value = "1" & gt; Apple & lt; / Option & gt; & Lt; Option value = "2" & gt; Orange & lt; / Options & gt; & Lt; Option value = "3" & gt; Pineapple & lt; / Options & gt; & Lt; Option value = "4" & gt; Banana & lt; / Options & gt; & Lt; / Select & gt; & Lt; Select class = "car" & gt; & Lt; Option value = "1" & gt; Volvo & lt; / Options & gt; & Lt; Option value = "2" & gt; Saab & lt; / Options & gt; & Lt; Option value = "3" & gt; Mercedes & lt; / Options & gt; & Lt; Option value = "4" & gt; Audi & lt; / Options & gt; & Lt; / Select & gt;
JQuery
$ (function () {$ ('.food'). Change (function () {fruitNum = $ (this) .val ();}); $ ('Car'). Change (function () {carNum = $ (this) .val ();}); adding both values of the fruit and nano}}} < / P>
If you want a dynamic update of prices, you can create a "callback" function which changes each time to select. By using the javascript parseInt function you can create a Can convert the selected value into an integer and a mathematical value .
$ (function () {$ ('.fruit'). Change (function () {function name = $ (this) .val (); clique (); Change (function.) {CarNum = $ (this) .val (); clack ();}); // Callback function that adds to the function () {results = PurseInt ($ ('.car'). Val ()) + parseInt ($ ('.food') .val ()); console.log result);}});
here
Comments
Post a Comment