javascript - Check if value existed in an HTML table column, jquery - Stack Overflow

To enter the ID number in a textbox it displays me the location on the scale in the other textbox. As i

To enter the ID number in a textbox it displays me the location on the scale in the other textbox. As in this jsFiddle: /

If the type a User ID number that does not exist in table it returns me the warning "No ID Number". Is it possible to do this?

$( "button" ).click(function() {
    var inputValue = $('#inputCell').val(); //User Digit

    //Convert Object
    var table = $('#tableHtml');

    //Verify blank value
    if( inputValue == ""){
        alert('Digit Number Id!');
    }
    else{


      //Check exist value !!!!!
       if($(table).find("tr").eq(inputValue).text() == ""){
        //find cell
         var valuefinal = $(table).find("tr").eq(inputValue).find("td").eq(1).text();
         $('#valueCell').val(valuefinal);
       }
       else{
        alert('No ID Number!');
       }


    }
    });

Solution

 var inputValue = $('#inputCell').val(); //User Digit
            //Convert Object
            var table = $('#tableHtml');
            //find cell
            var valuefinal = $(table).find("tr").eq(inputValue).find("td").eq(1).text();


            $('#valueCell').val(valuefinal);

            //Check exist value

            if (valuefinal == "") {
                alert("Not found");
                cleanInput();
             }

To enter the ID number in a textbox it displays me the location on the scale in the other textbox. As in this jsFiddle: http://jsfiddle/JoaoFelipePego/SdBBy/310/

If the type a User ID number that does not exist in table it returns me the warning "No ID Number". Is it possible to do this?

$( "button" ).click(function() {
    var inputValue = $('#inputCell').val(); //User Digit

    //Convert Object
    var table = $('#tableHtml');

    //Verify blank value
    if( inputValue == ""){
        alert('Digit Number Id!');
    }
    else{


      //Check exist value !!!!!
       if($(table).find("tr").eq(inputValue).text() == ""){
        //find cell
         var valuefinal = $(table).find("tr").eq(inputValue).find("td").eq(1).text();
         $('#valueCell').val(valuefinal);
       }
       else{
        alert('No ID Number!');
       }


    }
    });

Solution

 var inputValue = $('#inputCell').val(); //User Digit
            //Convert Object
            var table = $('#tableHtml');
            //find cell
            var valuefinal = $(table).find("tr").eq(inputValue).find("td").eq(1).text();


            $('#valueCell').val(valuefinal);

            //Check exist value

            if (valuefinal == "") {
                alert("Not found");
                cleanInput();
             }
Share Improve this question edited Jun 15, 2014 at 22:38 pegoj asked Jun 15, 2014 at 21:54 pegojpegoj 671 silver badge8 bronze badges 1
  • 1 An easy way to do this is: after var valuefinal = $(tab... add this: if ( valuefinal == "" ) alert("Not found"); – user3728078 Commented Jun 15, 2014 at 22:01
Add a ment  | 

1 Answer 1

Reset to default 4

WORKING DEMO

$( "button" ).click(function() {
    var inputValue = $('#inputCell').val(); //User Digit

    //Convert Object
    var table = $('#tableHtml');

    if( inputValue > table.find('tr').length - 1 ) {
        alert('No ID Number');
    } else
    //Verify blank value
    if( inputValue == ""){
        alert('Digit Number Id!');
    }
    else{


        //find cell
        var valuefinal = $(table).find("tr").eq(inputValue).find("td").eq(1).text();


        $('#valueCell').val(valuefinal);
    }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745439255a4627755.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信