javascript - JQuery/AJAX update DIV from MYSQL - Get values from different input 2 inputs -
i bit new jquery , have script values text input on onchange event , send data external php file can data db in fetch div id "txthint3".
the whole script works fine problem have need values 2 different text input fields , send 2 values php file.
essentially if 1 of 2 input text changes, need push 2 values jquery , php script.
i have tried few different ways without significant result. help/ideas appreciated!!
here jquery code wrote far :
<script> function recordtrans(str) { if (str == "") {`enter code here` document.getelementbyid("txthint3").innerhtml = ""; return; } else { if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("txthint3").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("get","recordtransaction.php?pos=1&code="+str,true); xmlhttp.send(); } } </script> function recordtrans(str) { if (str == "") { document.getelementbyid("txthint3").innerhtml = ""; return; } else { if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("txthint3").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("get","recordtransaction.php?pos=1&code="+str,true); xmlhttp.send(); }
and here html table/form :
<table class="table table-striped" id="financialdatatable"> <thead> <tr> <th style="width: 10%;">code</th> <th style="width: 5%;">qté</th> <th style="width: 25%;">produit</th> <th style="width: 25%;">description</th> <th style="width: 25%;">prix</th> <th style="width: 10%;">action</th> </tr> </thead> <tbody> <tr> <td> <div class="form-group"> <input type="text" id="code" name="code" class="form-control" onchange="recordtrans(this.value)" /> </div> </td> <td> <div class="form-group"> <input type="text" name="qte" id="qte" class="form-control" value="1" onchange="recordtrans(this.value)" /> </div> </td> <td colspan="3"><div id="txthint3" style="width: 100%"> </div></td> <td><button type="button" class="btn btn-primary btn-sm" onclick="$(this).addclone();">ajouter un autre article</button></td> </tr> </tbody> </table>
<input type="text" id="code" name="code" class="form-control" onchange="oncode_change(this.value)" />
function oncode_change(str){ var qteval = $("#qte").val(); recordtrans(str,qteval ) } function onqte_change(str){ var codeval = $("#code").val(); recordtrans(codeval,str) } function recordtrans(codeval, qteval) { ...your ajax call here }
Comments
Post a Comment