G
Geoff
I have been asked to add postal rates to a web page shopping cart checkout
procedure. After contacting the post office I discovered that they used XML
to receive postal rate requests and send back the rate for a certain size,
"from:" address, "To:" address and delivery service speed. The examples
they showed used a HTML "Text Area" and a HTTP post statement to send the
request however I need to use input from an input box and then insert this
information into the HTTP post. I have tried using variables but they are
sent literally rather than being substituted with the information from the
input statements. Is there a way to include the variable information as
part of the post? I am new to XML and would have thought that variable
substitution should be easy however I had no luck. I have included a
stripped version of the sample code below:
<HTML>
<BODY>
<script>
function go()
{
document.MyForm.action =
"http://"+document.Config.IP.value+":"+document.Config.PORT.value
document.MyForm.submit();
}
</script>
<CENTER><H3>Sample HTTP Request to eParcel</H3></CENTER>
<FORM name=Config>
<CENTER>
Server IP Address <INPUT size = 15 name=IP value="206.191.4.228">
and port (TCP) <INPUT size=5 name=PORT value="30000">
</CENTER>
<CENTER>
Postal Code: <INPUT size = 6 name=fpc value=""> <!--
Variable assigned value here -->
</CENTER>
<CENTER>
</FORM>
<FORM METHOD=POST name="MyForm">
<CENTER>
<TEXTAREA NAME=XMLRequest ROWS=20 COLS=80>
<?xml version="1.0" ?>
<eparcel>
<ratesAndServicesRequest>
<!--**********************************-->
<!-- Merchant Identification assigned -->
<!-- by Canada Post -->
<!-- -->
<!-- Note: Use 'CPC_DEMO_HTML' or ask -->
<!-- our Help Desk to change your -->
<!-- profile if you want HTML to be -->
<!-- returned to you -->
<!--**********************************-->
<merchantCPCID> 1234 </merchantCPCID>
<!--*********************************-->
<!--Origin Postal Code -->
<!--This parameter is optional -->
<!--*********************************-->
<fromPostalCode> t6a0h9 </fromPostalCode>
<postalCode> VARIABLE NEEDS TO GO HERE(fpc) </postalCode>
</ratesAndServicesRequest>
</eparcel>
</TEXTAREA>
<BR><BR>
<INPUT TYPE=SUBMIT VALUE="Submit XML request to eParcel via HTTP/POST"
onClick="go()">
</CENTER>
</FORM>
<BR><BR><BR>
</BODY>
</HTML>
procedure. After contacting the post office I discovered that they used XML
to receive postal rate requests and send back the rate for a certain size,
"from:" address, "To:" address and delivery service speed. The examples
they showed used a HTML "Text Area" and a HTTP post statement to send the
request however I need to use input from an input box and then insert this
information into the HTTP post. I have tried using variables but they are
sent literally rather than being substituted with the information from the
input statements. Is there a way to include the variable information as
part of the post? I am new to XML and would have thought that variable
substitution should be easy however I had no luck. I have included a
stripped version of the sample code below:
<HTML>
<BODY>
<script>
function go()
{
document.MyForm.action =
"http://"+document.Config.IP.value+":"+document.Config.PORT.value
document.MyForm.submit();
}
</script>
<CENTER><H3>Sample HTTP Request to eParcel</H3></CENTER>
<FORM name=Config>
<CENTER>
Server IP Address <INPUT size = 15 name=IP value="206.191.4.228">
and port (TCP) <INPUT size=5 name=PORT value="30000">
</CENTER>
<CENTER>
Postal Code: <INPUT size = 6 name=fpc value=""> <!--
Variable assigned value here -->
</CENTER>
<CENTER>
</FORM>
<FORM METHOD=POST name="MyForm">
<CENTER>
<TEXTAREA NAME=XMLRequest ROWS=20 COLS=80>
<?xml version="1.0" ?>
<eparcel>
<ratesAndServicesRequest>
<!--**********************************-->
<!-- Merchant Identification assigned -->
<!-- by Canada Post -->
<!-- -->
<!-- Note: Use 'CPC_DEMO_HTML' or ask -->
<!-- our Help Desk to change your -->
<!-- profile if you want HTML to be -->
<!-- returned to you -->
<!--**********************************-->
<merchantCPCID> 1234 </merchantCPCID>
<!--*********************************-->
<!--Origin Postal Code -->
<!--This parameter is optional -->
<!--*********************************-->
<fromPostalCode> t6a0h9 </fromPostalCode>
<postalCode> VARIABLE NEEDS TO GO HERE(fpc) </postalCode>
</ratesAndServicesRequest>
</eparcel>
</TEXTAREA>
<BR><BR>
<INPUT TYPE=SUBMIT VALUE="Submit XML request to eParcel via HTTP/POST"
onClick="go()">
</CENTER>
</FORM>
<BR><BR><BR>
</BODY>
</HTML>