Trying to put text in <select> with ajax

Obewrisee

New Member
So I am trying to put the GET of the ajax request in the \[code\]<select>\[/code\] using an id but it doesn't work. However when I use for example \[code\]<p>\[/code\] with an id or \[code\]<option>\[/code\] or anything else it does work and output what I want.This is my Ajax script\[code\] <script> function showUser(str) { if (str=="") { document.getElementById("brand").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 && xmlhttp.status==200) { document.getElementById("brand").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","inc/parts_form2.php?q="+str,true); xmlhttp.send(); }\[/code\]This is a part of the form\[code\]Year: <select onchange="showUser(this.value)">\[/code\]%year%
Brand: \[code\]<select id="brand"></select>\[/code\]And this is my php\[code\]<?php$q = $_GET['q'];echo $q;?>\[/code\]I am trying to get the output in \[code\]<select id="brand"></select>\[/code\]. Which I check in the source code if it worked.
 
Back
Top