Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I read a variable output from an html form and use it in the webpage?
    primarykey
    data
    text
    <p>OK, I've tried to get this to work - but just can't seem to see the way...</p> <p>What I am trying to do is have a form ask for an index, when I submit it will read an XML file (bowlist.xml) and give me the data for the matching index.</p> <p>Here is the entire code:</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;form action=""&gt; Bowl #: &lt;input type="text" name="bowlidx" value="" /&gt;&lt;br /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; var index = &lt;%=Request.QueryString(bowlidx)%&gt; document.write('index is ' + index) 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","bowlist.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.write("&lt;table border='1'&gt;"); var x=xmlDoc.getElementsByTagName("product"); for (i=0;i&lt;x.length;i++) { if(x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue != index) continue; document.write("&lt;tr&gt;&lt;td&gt;"); document.write(x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue); document.write("&lt;/td&gt;&lt;td&gt;"); document.write(x[i].getElementsByTagName("code")[0].childNodes[0].nodeValue); document.write("&lt;/td&gt;&lt;td&gt;"); document.write(x[i].getElementsByTagName("image")[0].childNodes[0].nodeValue); document.write("&lt;/td&gt;&lt;/tr&gt;"); } document.write("&lt;/table&gt;");&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I get the form, enter and submit the index, and nothing happens.</p> <p>Where am I going wrong on this?</p> <p>I should add that the javascript search does work if I enter an existing index in the "if(x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue != index)" line.</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.
 

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