i have this code in ASP, I need to do the same, b开发者_开发问答ut from the client side. I´ve been searching but i couldn´t do the javascript work. I think this would be pretty simple.
protected void btnProbar_Click(object sender, EventArgs e)
{
bool flag = false;
foreach(GridViewRow c in grdDatos.Rows)
{
if (c.Cells[0].Text == txtNroUnidad.Text)
{
flag = true;
}
}
}
If you could help me, I would apreciate that. Thanks you!
This is unchecked but it should be something like:
function ProBar
{
// Declare the flag
var flag = false;
// Get the text we want to compare in the table
var checkText = document.getElementById('txtNroUnidad').value;
// Get the grid
var grdDatos = document.getElementById('grdDatos');
// Loop through each row
// Starts at row 1 because I assume row 0 is a header row
for (i=1;i<=grdDatos.rows.length;i++)
{
var currentRow = grdDatos.rows[i];
if (currentRow.cells[0].value == checkText)
{
flag = true;
}
}
return flag;
}
精彩评论