Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

javascript\jquery

Hi Guys,

I am trying to loop through my table with javascript:

Here is my dom:
Note: this table is getting 5 rows:
<table class="table table-bordered" id="tableid">
    <thead>
        <tr>
            <th>Itemlookup</th>
            <th>Description</th>
            <th>Option</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    <input type="text" value="@item.ItemLookupCode" id="itmlookupid" />
                </td>
                <td>
                    <input type="text" value="@item.Description" id="descid" />
                </td>
                <td>
                    <a id="editme" onclick="getRows()">edit </a>
                    <input type="hidden" value="@item.ID" id="iddata" />
                </td>
            </tr>
        }
    </tbody>

</table>

Open in new window


Now this is what I'm doing in my javascript code:

 function getRows() {
            var table = document.getElementById("tableid").tBodies[0]
            debugger;
            for (var i = 0; i < table.rows; i++) {
                debugger;
                var rownum = i;
            }

        }

Open in new window


I'm trying to loop through the table and get number of rows. The issue is that it loops once and finish the loop.
Usually I do these things with jquery which is very easy, but I would like to do it with javascript this time.

Please, any help.
ASKER CERTIFIED SOLUTION
Avatar of Moti Mashiah
Moti Mashiah
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moti Mashiah

ASKER

solved