Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Title: Inserting Input data into a HTTP post. (best)

Status
Not open for further replies.

clasikcars

Programmer
Joined
Jun 5, 2004
Messages
3
Location
CA
(Sorry for the confusion , I was not sure what code to include. This is correct)

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.

Code:


<HTML>

<BODY>
<script>
function go()

{
document.MyForm.action =
" 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>

[/code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top