3/26/2009

Exercise 9-3

9.3. Can you modify the scripts to process the form?

Yes, i can use the html form named ex9.html which is created in exercrise 9.1 for passing the data by the perl, python & javascript, and use them to print out info from ex9.html.

A. PERL

First, i create a perl file named ex93.pl with the following code:
























Secord, set the action attibute to "/cgi-bin/ex93.pl" in ex9.html, like this
( FORM METHOD="post" ACTION="/cgi-bin/ex93.pl")

Third, access ex9.html, input info in ex9.html and click submit button
























Third, check the result in ex93.pl













It works!!!!!!


B.PYTHON

First, create a python file named ex93.py with following code:













Second, set form method with post and hardcord the action location in ex93.html
FORM METHOD="post" ACTION="/cgi-bin/ex93.py"

Third, access ex9.html, input the information and click submit button.






















Fourth, check the result.























It works!!!!!!

C. Javascript

First, create a html file named ex93_java.html which is embedded the javascript is used for querying form data with following code.


















Second, set form action to [ form onSubmit="return false" ] in the ex9.html and add a form submittted button with following code

[ input onclick="window.location.href = 'ex93_java.html?' + 'first='+ this.form.first.value + '&' + 'last='+ this.form.last.value + '&' + 'paymethod='+ this.form.paymethod.value + '&' + 'cardno='+ this.form.cardno.value + '&' + 'cardexp='+ this.form.cardexp.value" type="button" value="Submit" ]

Third, access the ex9.html, input information and click submit button.























Fourth, check the result!

It works!!

沒有留言:

發佈留言