Note that there are some explanatory texts on larger screens.

plurals
  1. POCant get javascript to create links correctly from XML list
    text
    copied!<p>Im trying to create a HTML table with links from a XML file using javascript. The html tbale works fine but when it comes to the link creation it seems the links only have the first word of my string in the link. IF i do an alert(String) command i get the full string but as soon as i try to make an HTML LINK it only adds the first word. </p> <p>Example:</p> <p>Base link: <a href="http://kat.ph/usearch/" rel="nofollow">http://kat.ph/usearch/</a>{SEARCH FIELD GOES HERE} String output from XML List : "Hello Sir"</p> <p>Actual Output as link (without quotes): <strong>"http://kat.ph/usearch/Hello"</strong> Expected output as link (without quotes): <strong>"http://kat.ph/usearch/Hello Sir"</strong></p> <p>Code is below</p> <pre><code> &lt;script type="text/javascript"&gt; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","playlist.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.write("&lt;table border='1'&gt;"); var x=xmlDoc.getElementsByTagName("void"); for (i=0;i&lt;x.length;i++) { document.write("&lt;tr&gt;&lt;td&gt;"); document.write(x[i].getElementsByTagName("string")[0].childNodes[0].nodeValue); document.write("&lt;/td&gt;&lt;td&gt;"); //alert(x[i].getElementsByTagName("string")[0].childNodes[0].nodeValue); just testing to see what i get here // document.write("&lt;a href=http://www.kat.ph/usearch/" + x[i].getElementsByTagName("string")[0].childNodes[0].nodeValue + "&gt;"+"KAT.PH"+"&lt;/a&gt;"); document.write("&lt;a href='" + "http://www.kat.ph/usearch/" + x[i].getElementsByTagName("string")[0].childNodes[0].nodeValue + "'&gt;" + "KAT.PH" + "&lt;/a&gt;"); document.write("&lt;/td&gt;&lt;/tr&gt;"); } document.write("&lt;/table&gt;"); &lt;/script&gt; </code></pre>
 

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