awebbdesign Posted May 2, 2007 Share Posted May 2, 2007 I have started to play with Ajax and have had some results, however to do a dual combo box for IE I had to write some XML as IE hates innerHTML. Anyhow The code below works except for the fact that in the for loop its printed literally, for some reason I can't use double qoutes, can anyone help! <?php header("Content-Type: text/xml"); require('adminarea/inc-connect.php'); //$id = $_GET['q']; $id = 3914; $from = mysql_query("SELECT tdata.*, tdata.fieldb AS theplace, tjoins.* FROM tdata LEFT JOIN tjoins ON tdata.id = tjoins.tdata_fk WHERE tjoins.tdata_id = '$id' ORDER BY tdata.fieldb"); $num = mysql_num_rows($from); print '<?xml version="1.0" encoding="ISO-8859-1" ?> <selectChoice><selectElement><formName>myform</formName><formElem>s2</formElem></selectElement>'; if(mysql_num_rows($from) != 0) { print "<entry><optionText>Select...$id, $num</optionText><optionValue>NS</optionValue></entry>"; for ($i = 0; $i < mysql_num_rows($from); $i++) { $row = mysql_fetch_object($from); print '<entry><optionText>$row->theplace</optionText><optionValue>$row->theid</optionValue></entry>'; } } else { print "<entry><optionText>No Options ($id, $iid)</optionText><optionValue>NA</optionValue></entry>"; } print "</selectChoice>"; ?> Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted May 2, 2007 Share Posted May 2, 2007 single quotes wont work there, you need to use double... if you say you can't use double quotes (I have no idea why not) you could do... <?php print '<entry><optionText>'.$row->theplace.'</optionText><optionValue>'.$row->theid.'</optionValue></entry>'; ?> Quote Link to comment Share on other sites More sharing options...
awebbdesign Posted May 2, 2007 Author Share Posted May 2, 2007 Hmmm, 1st thing I tried, I am suspecting now it could be the parser, is there anything wrong with the following??? function FillDropDown(){ var xmlDoc = this.req.responseXML.documentElement; //alert(xmlDoc); var xSel = xmlDoc. getElementsByTagName('selectElement')[0]; var strFName = xSel. childNodes[0].firstChild.nodeValue; var strEName = xSel. childNodes[1].firstChild.nodeValue; var objDDL = document.forms[strFName]. elements[strEName]; objDDL.options.length = 0; var xRows = xmlDoc. getElementsByTagName('entry'); for(i=0;i<xRows.length;i++){ var theText = xRows. childNodes[0].firstChild.nodeValue; var theValue = xRows. childNodes[1].firstChild.nodeValue; var option = new Option(theText, theValue); objDDL.options.add(option, objDDL.options.length); } } The website Im getting this to work on is: http://www.v-cars.com/bka3.php Any help will be most grateful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.