Joe I get the error after changing the quantity and tabbing or clicking o the screen to invoke the updateTotal function.
Below is the HTML Code
<html>
<head>
<title>Get Tester</title>
<script language="JavaScript">
function updateTotal(){
var qty = orderForm.qty.value;
var unitPrice = orderForm.unitPrice.value;
xdDoc = new ActiveXObject("MSXML.DOMDocument");
xhHTTP = new ActiveXObject("MSXML2.XMLHTTP");
xhHTTP.open("GET", "http://localhost/ASP/updateTotal2.aspx?quantity=" + qty + "&unitPrice=" + unitPrice, false);
xhHTTP.send();
xdDoc = xhHTTP.responseXML;
alert(xdDoc.xml);
var discount, extPrice;
discount = xdDoc.selectSingleNode("//o:discount").text + "% off";
xtPrice = xdDoc.selectSingleNode("//o:extPrice").text;
document.getElementById("discount").innerHTML = discount;
orderForm.extPrice.value = extPrice;
}
</script>
</head>
<body>
<h1>SOAP Pricing Tool</h1>
<form name="orderForm" id="orderForm">
Quantity: <input id="qty" name="qty" size="3" value="1"
onChange="updateTotal();"/>
<br />
Item: <i>Zibka Smiles</i>, by The Polka Dot Zither Band
<br />
Discount: <span id="discount"></span>
<br />
Unit Price: <input id="unitPrice" name="unitPrice" value="12.95" size="4"/>
<br />
Extended Price: <input id="extPrice" name="extPrice" size="4" value="12.95"/>
</form>
</body>
</html>
Below is the ASPX code
<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"
Dim quantity, unitPrice
Dim discount, extPrice
On Error Resume Next
quantity = Request.QueryString.Item("quantity")
unitPrice = Request.QueryString.Item("unitPrice")
discount = QuantityDiscount(quantity)
extPrice = (CDbl(quantity) * CDbl(unitPrice))*(1 - (discount/100))
If Err.number <> 0 Then
Response.Write (ErrorXML())
Else
Response.Write (SuccessXML(discount, extPrice))
End If
Function QuantityDiscount(quantity)
'For the sake of the example, just return a fixed amount
QuantityDiscount = 10
End Function
Function ErrorXML()
Dim sXML
sXML = "<Error><Reason>Invalid numbers</Reason></Error>"
ErrorXML = sXML
End Function
Function SuccessXML(sDiscount, sExtprice)
Dim sXML
sXML = "<env:Envelope xmlns:env='http://www.w3.org/2003/05/soap-envelope'>"
+ vbNewLine & "<env:Body>"
+ vbNewLine & "<o:updateTotalResponse "
+ "xmlns:o='http://www.sernaferna.com/soap/ordersystem'>"
+ vbNewLine & " <o:discount>" & discount & "</o:discount>"
+ vbNewLine & " <o:extPrice>" & extPrice & "</o:extPrice>"
+ vbNewLine & "</o:updateTotalResponse>"
+ vbNewLine & "</env:Body>"
+ vbNewLine & "</env:Envelope>"
SuccessXML = sXML
End Function
%>
|