Saturday, 15 January 2011

php - How to display all checkboxes values in a div using ajax -


I have multiple checkboxes displayed from the MySQL table. I all the code & lt; Div & gt; I'm trying to use AJAX from . Currently, my code is only for one checked value to be & lt; Div & gt; Sends to . I have a & lt; Div & gt; I want to display all checked values ​​in .

What's so far away from me:

   & Lt ;! - Display all checkboxes in the MySQL table, pass IDs from the name attribute - & gt; & Lt ;? Php}? & Gt;  

AJAX

  & lt; Script & gt; Function showPrice (name) {$ .ajax ({url: 'ajax_price.php', type: 'GET', data: {option: name}, success: function (data) {document.getElementById ('c'). InnerHTML = data;}}); } & Lt; / Script & gt; Include  

ajax_price.php

  & php ("../supplier/DB/db.php"); $ Id = $ _REQUEST ['Options']; & Lt ;? Php $ sql = "SELECT * FROM option WHERE op_id = '". $ Id "'"; $ Result = mysql_query ($ sql); While ($ line = mysql_fetch_array ($ result)) {? & Gt; & Lt; Div class = "oder" & gt; & Lt; Div class = "odercol2" & gt; & Lt ;? Php echo $ line ['op']; ? & Gt; & Lt; / Div & gt; & Lt; Div class = "odercol3" & gt; & Lt ;? Php echo $ line ['value']; ? & Gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;? Php}? & Gt;   

This & lt; Div & gt; has a display with only one checked value. I see my and

: //i.stack.imgur.com/lRINm.jpg "alt =" checkbox ">

display the results in this division

Just change your AAAGF function to insert the internal HTML of the DIV, like:

 
& lt; script & gt; function showPrice (name) {$ .ajax ({url: 'ajax_price.php', type: 'GET', data: {option: name}, success: function (data) {document .getElementById ('c'). InnerHTML + = Data;}}}}

Note this line document.getElementById ('c'). InnerHTML + Data; Hope this will work thanks


No comments:

Post a Comment