0

greeting to all, is there any way to get value in second text box, i have some filed as shown in my image,enter image description here if we type 90 in result text box then automaticaly the value of nor/ab field should be "Low", for 180 should be high. so we have to check over condition for 110-170(range field)...

actualy i am puzzled for the value of range field in the form of 110-170.... Any idea will be appreciated....thanks in advance...

Dinesh
  • 447
  • 1
  • 6
  • 22
  • Here you go; http://stackoverflow.com/questions/1280499/jquery-set-select-index. `if (result.value < 90) { /* Do link-code here, with low */ } else if (result.value > 180) { /* Do link-code here, with high */ } else { Do link-code here, with normal }` –  Apr 17 '13 at 11:30

4 Answers4

1

Try to do this way:

var result = $('#result');
var sel = $('#select');

result.on('keydown keyup', function () {
   if (result.val() < 90) {
      $('option[value="low"]', sel).prop('selected', true);
    } else if (result.val() > 90) {
      $('option[value="high"]', sel).prop('selected', true);
    }
});

Demo Fiddle

Jai
  • 74,255
  • 12
  • 74
  • 103
0
var result = $("#result").val();
if(result >= 110 || result <=170){
 $("#nor").val('Normal');
}
else if(result == 90){
  $("#nor").val('Low');
}
else if(result == 180){
  $("#nor").val('High');
}
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
  • sir i do not have only 110-170 value for range field...these are coming from database for specific test...so i have to fix some condition on result field for range field but range field are in the form like 110-170..so i am confused..... – Dinesh Apr 17 '13 at 11:39
  • @Jack for that you can add else condition at last of above answer that will show high if it goes above 180 – Sangna Jani Apr 17 '13 at 11:47
0

Assuming your row is wrapped in a parent div:

$('.result').change(function(){
    level = (($(this).val() < 170) ? 'low' : 'high');
    $(this).parent().find('.nor').val(level);
}
skndstry
  • 678
  • 1
  • 7
  • 21
  • sir i do not have only 110-170 value for range field...these are coming from database for specific test...so i have to fix some condition on result field for range field but range field are in the form like 110-170..so i am confused – Dinesh Apr 17 '13 at 11:41
0

It can be improved to be a bit more readable if needed, but it should do the trick:

$("#result").on('keyup',function(){
    if($(this).val()<110){
    $("#select").val("low");
    }
    else if($(this).val()<=170){
        $("#select").val("normal");
    }
    else{
            $("#select").val("high");
    }
})

http://jsfiddle.net/YWUrR/

DVM
  • 1,229
  • 3
  • 16
  • 22