The following script should do:
When a value is entered in the input, the outcome (in an other div) should be multiplied with a number. This number changes, when other select option is chosen.
Code
$('#dePlooi').change(function(){
if ($("#dePlooi").val() == "2") {
$("#txt_name").on("keyup change", function() {
var value = this.value;
var valuemath = value * 2.5;
$("#dom_element").text(valuemath);
});
}
else if ($("#dePlooi").val() == "3") {
$("#txt_name").on("keyup change", function() {
var value = this.value;
var valuemath = value * 3;
$("#dom_element").text(valuemath);
});
} else if ($("#dePlooi").val() == "1") {
$("#txt_name").on("keyup change", function() {
var value = this.value;
var valuemath = value * 2;
$("#dom_element").text(valuemath);
});
}
});
This works a little, but only if a select option is chosen and then the input is changed. I want it to happen this way but ALSO it needs to change the input on select option change. So for example:
How do I make it so that when the input or the select option is changed, the event fires?
Fiddle: http://jsfiddle.net/eJvMb/