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);
}
});