Aurelijus1 Aurelijus1 - 1 year ago 151
HTML Question

How to define value in javascript

I tried to use $(".input-text").val() to define value but all code stop working, maybe there is other way that i can define it from input text? Here is that line:

var oMain = new CMain({
howmuch: $(".input-text").val()

Only works if i put number instead of $(".input-text").val()

Answer Source

$(".input-text").val() returns string, so if CMain expects integer in howmuch you need to convert value to integer:

howmuch: parseInt($(".input-text").val())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download