be_good_do_good
be_good_do_good

Reputation: 4441

send table contents in a form on submit through request.POST in django

I have an form like below

   <form method="post" action={{ url/to/page }}>
       {% csrf_token %}
       <table>
       <tr>
           <td name="test">2</td>
           <td name="test1">3</td>
       </tr>
       </table>
       <input type="submit" value="submit">
   </form>

On pressing submit, request.POST dictionary received in views.py do not have the td elements? Can someone please help?

If i have an input readonly element inside td blocks, i can getting the data in request.POST dictionary

But I want to know if there is a way to get td elements innerHTML parts?

Upvotes: 1

Views: 2914

Answers (1)

olofom
olofom

Reputation: 6491

<td is not part of the form, it's for the styling. When submitting a form the fields in it will be submitted, nothing else. You can use hidden inputs if you want <input type="hidden" name="test" value="2"> will not be visible but submitted.

Try reading a bit about how forms works in HTML.

If you really want it in this way you can it to work with JavaScript instead.

Upvotes: 2

Related Questions