funbinod Posted May 29, 2014 Share Posted May 29, 2014 i was trying to get some value according to value entered to form <input> field. but it returns value only to another <input> field but not to <div>s or <span>s. i wonder what is the problem. here is what i tried // this is ajax script // get cqtyfunction getCqty(){var XMLHttpRequestObject;// ...............// ...............if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { document.getElementById('cqty').value = XMLHttpRequestObject.responseText;}}var icode = document.getElementById('icode').value;XMLHttpRequestObject.open('POST', 'ajax/cqty.php');XMLHttpRequestObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");XMLHttpRequestObject.send("icode=" + icode);} // this is cqty.php <?require_once('../functions.php');header("content-type: text/xml");$icode = trim($_POST['icode']);$sql = mysqli_fetch_object(mysqli_query($connect, "select * from stock where icode='$icode'")) or die(mysqli_error($connect));$item = $sql->item;$unit = $sql->iunit;$sid = $sql->sid;$oqty = $sql->oqty;$sql1 = mysqli_fetch_array(mysqli_query($connect, "select sum(pqty),sum(sqty) from tran where sid=$sid")) or die(mysqli_error($connect));$pqty = $sql1['sum(pqty)'];$sqty = $sql1['sum(sqty)'];$cqty = $oqty + $pqty - $sqty;echo "( " . $cqty . " " . $unit . " )";?> and this is client side <tr> <td align="right">Item Code: </td> <td> <input type="text" name="icode" id="icode" onkeypress='return tabE(this,event)' onchange="getRate();getItem();getCqty()" /> </td></tr><tr> <td align="right" width="100px">Item Name:</td> <td> <input name="item" id="item" onkeypress='return tabE(this,event)' /><!-- value returns fine here. but if i used <div> or <span> in stead of <input>, nothing is displayed--> </td></tr> can anyone please help me find out the problem... Link to comment Share on other sites More sharing options...
davej Posted May 29, 2014 Share Posted May 29, 2014 You can't use .value with a div or a span. You have to use .innerHTML. Link to comment Share on other sites More sharing options...
funbinod Posted May 29, 2014 Author Share Posted May 29, 2014 wow! that's great. i didn't notice that. thank u very much.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now