I have a dynamically obtained Listview with a H3 and 2 P tags. As in:
<li>
<h3>Product no.4</h3>
<p><strong>Product description</strong></p>
<p>_price_</p>
<p>_quant_</p>
<p class="ui-li-aside"><strong>productID</strong></p>
</li>
The listview may contain 1 items (li) or 10-15 items. I cannot know from the beginning. I also have a button on my page that Is destined to save the contents of the listview to a database. I actually need the productID, quant and price TAG contents from all the list items in order to be able to save the item properly in my database. How can I get each list item's inner tags so I can post them to a PHP that will do the work?
Is there a way to send all list items in one post so there would be no lost items?
I assume I should have the listview inside a form and the button onclik should be something like:
$("#saveinv").click(function() { //When save button is clicked...
var optionTexts = [];
$("#listaproduse li").each(function() { optionTexts.push($(this).text()) });
var text = '"' + optionTexts.join('"<br/> "') + '"';
... some post function here...
});
But I have no idea how to post a form containing dynamic elements from jquery.
Any help would be appreciated
content in order to add it to the JSON ?** I tried to do it like listview_el.prodid=$(this).find('p').eq(4).text(); but it does not seem to work like that.
– user1137313 Jul 11 '13 at 08:48