admin管理员组文章数量:1424955
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
1 Answer
Reset to default 4WORKING 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);
}
});
本文标签: javascriptCheck if value existed in an HTML table columnJQueryStack Overflow
版权声明:本文标题:javascript - Check if value existed in an HTML table column, jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745439255a2658371.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论