Can you getElementsByName if you only have partial name on javascript?
html, javascript
Solution
This is not possible. I'm assuming for the rest of this answer that the elements you're interested in are `<td>`s. If so, then you should be aware that the `name` attribute is not valid for `<td>` elements.
You will have to create a list of matching elements manually. If you decide to use the `name` attribute anyway (instead of, say, adding a class in the `class` attribute), something like the following will work:
var table = document.getElementById("your_table_id");
var tds = table.getElementsByTagName("td");
var matchingTds = [];
for (var i = 0, len = tds.length, td, tdName; i < len; ++i) {
td = tds[i];
tdName = td.getAttribute("name");
if (tdName && tdName.indexOf("tdName_") == 0) {
matchingTds.push(td);
}
}
Problem
I have a repeating table where the name of the elements would be (e.g. 'tdName_1' 'tdName_2'), and I was wondering if it would be possible to getElementsByName('tdName_'). PS: I can not use Jquery. Thanks In advance. Cesar.