Why doesn’t the below work, and how should I do this?
Do you have a better and shorter way to write this code?
“.Select_unit” is the class name of Radiobutton.
$(function() {
var W_val;
var H_val;
//set width textbox Value to W_val
$('#input_2_1').keyup(function() {
W_val = $("#input_2_1").val();
});
//set Height textbox Value to H_val
$('#input_2_2').keyup(function() {
H_val = $("#input_2_2").val();
});
//Change Unit mm to cm
$('.Select_Unit input[type="radio"]').on('change',function(){
var radioValue = $('input[name="#input_2_3"]:checked').val();
if (radioValue=="cm")
{
$("#input_2_1").val(W_val);
$("#input_2_2").val(H_val);
}
else
{
$("#input_2_1").val((W_val*10));
$("#input_2_2").val((H_val*10));
}
});
});