有人问我是否可以使用一些表单数据并以 HTML 格式呈现。
我需要将 LOADS 数据/值相加并将其乘以 RATE 数据/值,我认为这会起作用,但它在我的浏览器中没有显示任何内容?
我哪里错了?
我是 JavaScript 新手,我有 HTML/CSS 技能。我知道 jQuery 可能是做这类事情的最好方法,但我不知道。
<html>
<script>
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","xmltest.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var k=xmlDoc.x[1].getElementsByTagName("LOADS");
var J=xmlDoc.x[1].getElementsByTagName("RATE");
{
document.write("<tr ><td>");
document.write(k*J);
document.write("</td><tr>");
}
document.write("</table>");
</script>
</html>
XML file
<MULTILOAD_TICKET>
<TICKET>
<DATE>12/11/12</DATE>
<ADDRESS>123 FAKE STREET</ADDRESS>
<RATE>300</RATE>
<LOADS>3</LOADS>
<CUSTOMER>Columbia Ales</CUSTOMER>
<ORDERID>BBKHJ1001</ORDERID>
<DRIVER>BOB</DRIVER>
<VEHICAL_REG>UJ78 JHE</VEHICAL_REG>
<MATERIAL>SPOIL</MATERIAL>
<SIG>URL</SIG>
</TICKET>
<TICKET>
<DATE>12/11/12</DATE>
<ADDRESS>123 FAKE STREET</ADDRESS>
<RATE>300</RATE>
<LOADS>6</LOADS>
<CUSTOMER>Columbia Ales</CUSTOMER>
<ORDERID>BBKHJ1001</ORDERID>
<DRIVER>JACK</DRIVER>
<VEHICAL_REG>EU78 JHD</VEHICAL_REG>
<MATERIAL>SPOIL</MATERIAL>
<SIG>URL</SIG>
</TICKET>
<TICKET>
<DATE>15/11/12</DATE>
<ADDRESS>123 FAKE STREET</ADDRESS>
<RATE>300</RATE>
<LOADS>5</LOADS>
<CUSTOMER>Columbia Ales</CUSTOMER>
<ORDERID>BBKHJ1001</ORDERID>
<DRIVER>BOB</DRIVER>
<VEHICAL_REG>UJ78 JHE</VEHICAL_REG>
<MATERIAL>SPOIL</MATERIAL>
<SIG>URL</SIG>
</TICKET>
</MULTILOAD_TICKET>