0

Screenshot 1 Based on some parameters, data is getting loaded whenever there is a single row of data. I can use the id of the div and then get the value of the textbox and other tags; but how do I same when there are multiple rows of data?

$("input").keydown(function(){

    var normal_val=$("#normal_val").text();
    var n_range = normal_val.split("-");
    var c_val=$("#critical_val").text();
    var c_range=c_val.split("-");
    var inp=$('#code input:text').val();
    var len=$('#code input:text').val().length;

    var inp=$('#code input:text').val();



    if(inp>=n_range[0] && inp<=n_range[1])
    {
        $("#code input").css("background-color", "#64FFDA");
        $("#code input").css("color", "#FAFAFA");
    }
    else if(inp>=c_range[0] && inp<=c_range[1])
    {
        $("#code input").css("background-color", "#D32F2F");
        $("#code input").css("color", "#FFF");
    }
    else if(inp<n_range[0])
    {
        $("#code input").css("background-color", "#A7FFEB");
        $("#code input").css("color", "#FFF");

    }
    else if(inp>n_range[1])
    {
        $("#code input").css("background-color", "#FF5252");
        $("#code input").css("color", "#FFF");

    }
    else{
        $("#code input").css("background-color", "#FF8F00");
    }

Screenshot 2

  • It is bad to use same ID as #normal_val all over the page. Lets say it is a table row anyway (you haven't posted html part), than you should go on keydown this way: normal_val=$(this).closest('tr').find('#normal_val').text(), hope you get it. – skobaljic Sep 20 at 8:37
  • no its not a table row there is a div class="row" and then inside it there are multiple col-sm-2 div – Ayan Bhattacharjee Sep 20 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.