A
A
Alex Kova2015-11-09 00:29:11
JavaScript
Alex Kova, 2015-11-09 00:29:11

How to send data using POST method from SPAN?

How to transfer data from a table using the POST method? There are no inputs, there are only spans and td-shki, the input is only for submission.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton B, 2015-11-09
@bigton

In any case, you will need to somehow indicate what you are going to send in POST. For example, add the data attribute to td <td data-row="3" data-col="2" data-val="456">. And then on submit, hang up a JS handler that will collect all the data-* information and send it to the server.
But, it's much easier to add <input type="hidden" name="td_1" val="23">.

F
fedot1325, 2015-11-09
@fedot1325

ajax

W
wellgo, 2015-11-09
@wellgo

JS generate the form and submit it. Or is there no JS either?;) It is
possible through data-attributes (code for jQuery):

<table id="table"><tr><td><span data-id="name">Иван Петрович</span></td></tr></table>
<script>
   var form = $('<form />');
   $('#table').find("td").each(function(k,v){
      $form.append('<input type="hidden" value="' + $(v).find('[data-id=name]').text() + '"');
   });
   $form.submit();
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question