0

Hi guys...

I need some help from you all..

Actual Scenario is :
This is Module to Update today's price of products and these TextBoxes below is created in loop with

<input type="text" id="<?="rate2".$i?>" name="<?="rate2".$i?>" size="5" />

($i is increment variable of loop) also I already got abc rate (Standard price).

Now Problem is :
Whenever user enters the value on 1 TBX it should compare this.value with abc rate and if this.value is low then entire row's text color should be red, so on. then finally, it should also highlight the lowest of all.

Please help me in this asap
Thanks in advance...

Attachments help.JPG 12.12 KB
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by anu013
1
<input id='rate1' value='5' onchange="checkValues('rate1','rate2');"/>
<input id='rate2' value='8' onchange="checkValues('rate1','rate2');"/>
<script type='text/javascript'>
function checkValues(eid1,eid2){
    var obj1 = document.getElementById(eid1);
    var obj2 = document.getElementById(eid2);
    if(parseFloat(obj1.value) < parseFloat(obj2.value)){
        obj1.style.backgroundColor = '#cc0000';
        obj2.style.backgroundColor = '#00cc00';
    }else if(parseFloat(obj1.value) > parseFloat(obj2.value)){
        obj2.style.backgroundColor = '#cc0000';
        obj1.style.backgroundColor = '#00cc00';
    }else{
        obj1.style.backgroundColor = '#cccc00';
        obj2.style.backgroundColor = '#cccc00';
    }
}
checkValues('rate1','rate2');
</script>
0

Hey Guys,

Thanks for your replies.. I got solution for first one (i.e. Comparing new value with abc and change color if new value is low) with the following code.

<input type="text" id="<?="rate2".$i?>" name="<?="rate2".$i?>" size="5" 
onkeypress="if( parseInt($(this).val()) < abc )$(this).css('background-color','red')"/>

but cant able to solve the second problem i.e. when user completes entering all seven values, it should automatically highlight the lowest value.

Thanks for your suggestions..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.