I have this great JavaScript that automatically populates the values of all textboxes on a page with a number, starting at 1 then increasing.
function editTextBoxes() {
var textboxs = $('input:text');
for (i = 0; i <= textboxs.length; i++) {
$('input:text:eq(' + i + ')').val(i + 1);
}
}
However, I only want to fill textboxes who’s id contain txtSortOrder.
Can someone please help me fix this line: (it’s just a guess)
if ($('input:text:eq(' + i + ')').ID.Contains("txtSortOrder")
You can pull any attribute using the
attrfunction. For theContains(), you can useindexOfwhich will return-1if the search is not found.So that brings us this far:
Now, for your iteration, you can actually use
eachto process the results of your query.E.g.
Notice this extends your selector to use Attribute Contains word Selector:
input:text[id~=txtSortOrder]Which means you do not have to do the ID comparison manually