CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Altering values in Textfield and re-displaying

 



mango
Novice

Mar 18, 2007, 2:48 PM

Post #1 of 5 (2282 views)
Altering values in Textfield and re-displaying Can't Post

I have this cgi program that contains a form with a textfield. The textfield accepts a phone number. If the user enters something like (999) 999-9999 or 999 999 9999, my program contains code to reformate the entered phone number to the 999-999-9999 format. That is the easy part. Now how do you get the reformated phone number (i.e. the altered parameter value) to display in the textbox after the user presses the Submit button?

For example I have :

$phone = param("phone");

Now I change the value of $phone to a 999-999-9999 format after the user enters his/her format. How do I get my altered $phone value to display in the textbox?

Does this require some fancy javascripting?


KevinR
Veteran


Mar 18, 2007, 11:48 PM

Post #2 of 5 (2275 views)
Re: [mango] Altering values in Textfield and re-displaying [In reply to] Can't Post

If you are displaying the reformated phone number after the submit button is clicked on, you would not use javascript. You would use the $phone variable. How you do it depends on your perl code though. You are using the CGI module to parse your form fields, are you also using the CGI module to generate the form widgets?
-------------------------------------------------


mango
Novice

Mar 19, 2007, 7:08 AM

Post #3 of 5 (2272 views)
Re: [KevinR] Altering values in Textfield and re-displaying [In reply to] Can't Post

Its just a simple program that generates the form widgets (i.e. a few textfields and a password_field). The user enters the information and presses submit; if all fields are OK, it redirects to another file.

I can change the format of the $phone value entered by the user and print it outside of the textfield widget, this is pretty standard (i.e. print "Your phone # is" , $phone;). But how do you get that value to change in the widget itself? The textfield is sticky...it just retains the value enterd by the user after you press the submit button.


KevinR
Veteran


Mar 19, 2007, 1:03 PM

Post #4 of 5 (2267 views)
Re: [mango] Altering values in Textfield and re-displaying [In reply to] Can't Post

The documentation for the CGI module should cover your situation.

http://perldoc.perl.org/CGI.html
-------------------------------------------------


mango
Novice

Mar 19, 2007, 3:28 PM

Post #5 of 5 (2264 views)
Re: [KevinR] Altering values in Textfield and re-displaying [In reply to] Can't Post

Ahh thanks you are a genius...

I used a simple code; param('phone', $phone) to take over the value, it worked.

Yes documentation manuals can be useful...patience, patience...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives