473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Inserting Input data into a HTTP post.

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.POR T.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>
Jul 20 '05 #1
3 4232


Geoff wrote:
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.


As long as you use a HTML page and want to post data to a server you
simply need to learn HTML and how use forms to post data:
<form action="whatever"
method="post">
<input type="text" name="from">
<input type="text" name="to">
...
<input type="submit">
</form>

Your code that you had below seems to rely on JavaScript to simply
submit a form which doesn't make sense as HTML can do that without any
need for script being supported and enabled in a browser.

As for the XML in that textarea could you provide a URL of that postal
service that clearly describes the input format and response format?
From your email address I guess it is a Canadian postal service, I have
had some look around on http://www.canadapost.ca/ but all I have found
is some instructions to apply for a shipping profile account.
It is also not clear to me whether a client side solution is really
helpful to you, I would rather expect that you would build a form to
send data to your own web server and there with some server side
processing like PHP or ASP you would then request shipping information
from that postal service server.

Thus if you provide more information someone here in this group can help
even if he is not familiar with that particular Candadian postal
service. But consider to also try a Canadian group, maybe that postal
service even runs an online forum for customers making HTTP shipment
requests.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Thanks so much for your reply Martin.

Here is a link to Canada Post - Sell Online Developer's Site :

http://206.191.4.228/DevelopersResou...lV3/index.html

Here is a sample page of my shopping cart:

http://www.hflags.com/demostore/html...uvenirs/02.htm

Although I have built a handful of java based shopping carts and html
forms generally, this is the first time I've been asked to integrate
this shipping module from Canada Post into a java based cart.

There is an asp option which is quite easy. Unfortunately this cart
resides on a unix based server.

Of Note:

"If you use Java: Sun's XML parser"

http://java.sun.com/xml/ Is this of any help?

Thanks, Geoff

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3


Geoff wrote:

Here is a link to Canada Post - Sell Online Developer's Site :

http://206.191.4.228/DevelopersResou...lV3/index.html

Here is a sample page of my shopping cart:

http://www.hflags.com/demostore/html...uvenirs/02.htm

Although I have built a handful of java based shopping carts and html
forms generally, this is the first time I've been asked to integrate
this shipping module from Canada Post into a java based cart.

There is an asp option which is quite easy. Unfortunately this cart
resides on a unix based server.


Well, you have to decide what you want and look at what is possible, you
have much of that shopping cart code in client side JavaScript but
somehow I think you also have server-side processing. I don't know what
language you use on the server, whether that is PHP or Perl or Java
(servlets or JSP). Normally you would build a HTML form for the user to
enter the shipping details you need and let the user submit that data to
your server where you process it with the language of your choice and
built the HTTP request to post to the XML to the postal server which
gives you a choice as I understand whether to answer with XML or HTML.
They have provided that form at
http://206.191.4.228/DevelopersResou...Interface.html
as an example to outline the XML to be sent but it clearly says

Normally, when you integrate eParcel into your website, this XML request
has to be sent by YOUR server (not by the consumer's browser)

so you do not need to worry on XML in a textarea or text input, your
clients should only see a form to enter the shipping details you need,
submit them with a normal HTML form to your server where you then have
to build the XML to post it to the Canada postal server.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
1
by: Geoff Wickens | last post by:
I am quite new to all this but am trying to create a database driven site. I have been able to use information from my sample database but I now want to be able to insert data into it. At present I...
6
by: 35th Ave Media | last post by:
Hello, I have about 60+ pages that I need to insert a MAILTO: tag so people can email the page using their email client. The body of the message is going to be the URL of that page. Using ASP,...
5
by: bob44 | last post by:
Hi, I recently created a mysql database using phpmyadmin. I then proceeded to make a form to insert data into the database, but the problem is that the form is only able to insert one record, and...
18
by: boss1 | last post by:
Hi all, i m having a problem with inserting data in oracle db. When i use form action =(call self page) then data is inserting properly.But problem with when using form...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
4
by: ghjk | last post by:
I wan to add some data using php page to mysql db. But I got the error saying "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right...
4
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.