How do I read a variable output from an html form and use it in the webpage?

hasnizam

New Member
OK, I've tried to get this to work - but just can't seem to see the way...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.Here is the entire code:\[code\] <!DOCTYPE html><html><body><form action="">Bowl #: <input type="text" name="bowlidx" value="" /><br /><input type="submit" value="http://stackoverflow.com/questions/10893607/Submit" /></form><script type="text/javascript">var index = <%=Request.QueryString(bowlidx)%>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("<table border='1'>");var x=xmlDoc.getElementsByTagName("product");for (i=0;i<x.length;i++) { if(x.getElementsByTagName("id")[0].childNodes[0].nodeValue != index) continue; document.write("<tr><td>"); document.write(x.getElementsByTagName("id")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x.getElementsByTagName("code")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x.getElementsByTagName("image")[0].childNodes[0].nodeValue); document.write("</td></tr>"); }document.write("</table>");</script></body></html>\[/code\]I get the form, enter and submit the index, and nothing happens.Where am I going wrong on this?I should add that the javascript search does work if I enter an existing index in the "if(x.getElementsByTagName("id")[0].childNodes[0].nodeValue != index)" line.
 
Back
Top