javascript - Ajax Return Value show on div but not show on input fields -


hi have ajax code can change innerhtml of div not work input text field.

this ajax code:

<script>  function hallprice(str) {      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("hallcharges").innerhtml = xmlhttp.responsetext;  }    }    xmlhttp.open("get","<?php echo base_url();?>admin/hallreservation/get_hallprice?q="+str,true);    xmlhttp.send();  }  </script>
<div id="hallcharges"></div>    <input id="hallcharges" name="hallcharges" type='text'  class="form-control" />

how update text field responsetext?

you have same id div , input, please change div id divhallcharges

if want show output in input use document.getelementbyid("hallcharges").value instead of document.getelementbyid("hallcharges").innerhtml

<div id="divhallcharges"></div>  <input id="hallcharges" name="hallcharges" type='text'  class="form-control" />  <script> function hallprice(str) {      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("hallcharges").value = xmlhttp.responsetext;         }     }      xmlhttp.open("get","<?php echo base_url();?>admin/hallreservation/get_hallprice?q="+str,true);      xmlhttp.send();  } 


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -