papashoot Posted August 24, 2012 Share Posted August 24, 2012 hi there since i am quite new in ajax and jquery, i like to ask a little help from the expert here. i have 2 combo box, lets say combo box A and combo box B, and the content of combo box B depends on selected combo box A it works perfectly the problem is I can pass the content of combo box A into database, but i can't pass the content of combo box B here is some code in my php file <tr> <td>Main Fault</td> <td > <select name="cmbf1" style="width:400px" onChange = "proses_fault()"> <option value="" selected></option> <?php $id_mysql = mysql_connect(SERVER_NAME, USER_NAME, PASSWORD); $db_jualanp1_scenter = mysql_select_db("jualanp1_scenter",$id_mysql); $sql = "SELECT * FROM fault order by fname"; $hasil= mysql_query($sql, $id_mysql); while ($baris = mysql_fetch_row($hasil)) { $cf1 = $baris[1]; print ("<option value = \"$cf1\">$cf1</option>\n"); } mysql_close ($id_mysql); ?> </select> </td> <td>Main SubFault</td> <td colspan="3"> <div id="datasub" name="cmbfs1"></div> </td> </tr> here is the ajax section function proses_fault() { var kode_fault = form.cmbf1.value; //if (! kode_fault) // return; xmlHTTP.open('get', 'getsubfault.php?id_fault=' + kode_fault, true); xmlHTTP.onreadystatechange = function () { if ((xmlHTTP.readyState == 4)) { document.getElementById("datasub").innerHTML = xmlHTTP.responseText; } } xmlHTTP.send(null); } here is the jquery <script> $(document).ready(function() { $('#submitAsAdd').click(function() { var content = $('#datasub').html(); $.ajax({ url: 'writefaultsub.php', type: 'POST', data: { content: content } }); }); }); </script> and here is writefaultsub.php <?php require_once "otentik.php"; if (!otentikasi_ok()) { header("Location: login.php?" . "pesan=Please Login First"); exit(); } //update trans detail $vjob = $_SESSION["jobno"]; $id_mysql = mysql_connect(SERVER_NAME, USER_NAME, PASSWORD); $db_jualanp1_scenter = mysql_select_db("jualanp1_scenter", $id_mysql); $sqlt = "update transdt set tdfsub1 = '$_POST[content]' where tdjob = '$vjob' " $hasil = mysql_query ($sqlt, $id_mysql); ?> can anyone here give me a solution? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/267518-how-to-pass-div-content-into-database/ Share on other sites More sharing options...
Christian F. Posted August 24, 2012 Share Posted August 24, 2012 Please use the tags around your code, as it helps make both your post and your code a lot easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/267518-how-to-pass-div-content-into-database/#findComment-1372156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.