javascript - how to display result in other text box with condition in jquery -
i have field
as shown in figure, if enter less 20 in result field nor/ab value should automaticaly changes "low" if entered more 110, should display high else normal. tried jquery , did not successed...let see form.
<div style=" width:900px; height:auto; float:left; text-align:center;"> <div style=" height:auto; width:140px; float:left">{title}</div> <div style=" height:30px; width:140px; float:left"><input type="text" height="30px" width="140" name="rep_result_{txt}" /></div> <div style=" height:30px; width:140px; float:left">{unit}</div> <div style=" height:30px; width:140px; float:left">{first_val} - {last_val}</div> <div style=" height:30px; width:140px; float:left"><input type="text" height="30px" width="140" name="remark_{txt}" >
you can see entered range value in 2 section first_val(means 20) , last_val(means 110), how can use jquery make complete(remember range value dynamic can't apply condition on 20,110)...thanks in advance
html
<input type='text' id='result' /> <input type='text' id='nor' data-min='20' data-max='110' />
javascript
$('#result').change(function() { var result = $(this).val(), nor = $('#nor'), min = nor.data('min'), max = nor.data('max'); if(result < min) { nor.val('low'); } else if (result < max) { nor.val('normal'); } else { nor.val('high'); } });
jsfiddle : http://jsfiddle.net/bbpc7/
may can helpful.