Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript html not working on chrome
    primarykey
    data
    text
    <p>I am working on this code to display the list of clients and onclick it populate the text field with the selected name and the hidden text field for the id.</p> <p>HTML</p> <pre><code>&lt;input type="hidden" id="id" value="" /&gt; &lt;input type="text" name="client" id="client" class="round full-width-input" value="Type a name..." onChange="searchClient()" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();" onfocus="if(this.value=='Type a name...') {this.value=''}" onblur="if(this.value == ''){this.value='Type a name...'; document.getElementById('search_results').innerHTML = '';}" /&gt; &lt;label style="margin:0 0 0 1%"&gt;&lt;i id="search_results"&gt;&lt;/i&gt;&lt;/label&gt; </code></pre> <p>Onchange it uses javascript to call a php file.</p> <p>Javascript</p> <pre><code>function searchClient() { var str = document.getElementById("client").value; if (str == "") { document.getElementById("search_results").innerHTML = ""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("search_results").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET","search_client.php?name="+str,true); xmlhttp.send(); } </code></pre> <p>The php file is returning the list and populates the label. Below is whats returning from PHP file</p> <pre><code>echo '&lt;a onClick="selectClient('.$fullname.','.$row[0].')"&gt; &lt;tr&gt;&lt;td class="cap"&gt;'.$fullname.'&lt;/td&gt;&lt;/tr&gt;&lt;/a&gt;'; </code></pre> <p>Then I can click on the list and it call javascript again to populate the text field.</p> <p>Javascript selectClient</p> <pre><code>function selectClient(name,id) { document.getElementById("id").value = id; document.getElementById("client").value = name; document.getElementById("search_results").innerHTML = ""; } </code></pre> <p>My problem is: This is not working on Chrome, but works nicely IE. Anyone knows what am I missing here?</p> <p>Thanks for help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload