1

actually i have a table in the html and i want to know how i can get like tabe.rows.count on python in web2py

here is my code:

<table id="TablaMateriales" name="TablaMateriales" class=" table table-responsive order-list">
    <thead>
        <tr class="table-light">
            <td>Item</td>
            <td>Descripcion</td>
            <td>Unidad</td>
            <td>Cantidad</td>
            <td>Proveedor</td>
        </tr>
    </thead>
    <tbody>
       <tr>
            <td>
                <input type="number" name="Item0" class="form-control" style="width:45px" value="1" disabled />
            </td>
<td>
                <input type="text" name="Unidad0" style="width:100px" class="form-control"/>
            </td>
            <td>
                <input type="number" min="0" id="Cantidad0" name="Cantidad0" style="width:75px" value="0" class="form-control" onFocus="this.select()" onsubmit="if(this == ''){$this.val('0');}"/>
            </td>
            <td>
                <input type="text" name="Proveedor0" style="width:250px" class="form-control"/>
            </td>
     </tr>
    </tbody>
</table>

and code behind:

def crearCotizacion():
    materialesT = request.vars.get('TablaMateriales')
    rowsCount = materialesT.rows.count
return dict(rowsCount = rowsCount)

Thank you!

1 Answer 1

0

It seems like you are trying to access a client side element ('TablaMateriales') on the server side. You can only do that if you explicitly pass the element back to the server.

And then you would need to manipulate it using something like http://web2py.com/books/default/chapter/29/05/the-views#Server-side-DOM-and-parsing

You could just count the number of rows using JavaScript from inside the view: JavaScript to get rows count of a HTML table

Sign up to request clarification or add additional context in comments.

1 Comment

thank you i think im going to use the javascript solution and add the response to a hidden :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.