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!

Processing Forms

Status
Not open for further replies.

webpager

Programmer
Joined
Mar 27, 2001
Messages
166
Location
GB
Hi All
I am processing an application form within a script and, as the visitors first attempt to send their details is usually incorrect I am returning the completed form with the incorrect fields highlighted. Normal text fields are no problem but I wonder if there is a simple way of returning the value of check boxes, drop down menus and all the other, more complicated form elements.
I could simply return the fields in which the error occurred but I have found that this confuses the visitor even more as they think their other info has been forgotten.
Thanks in nticipation
Keith
 
This is trivial if you use CGI.pm to generate your forms, it automatically should do this. If you need to manually implement you can just do :

print $query->radio_group(-name=>'group_name',
-values=>['eenie','meenie','minie'],
-default=>'meenie',
-linebreak=>'true',
-labels=>\%labels);


perldoc CGI for more info.



 
Thanks for the reply siberian but I'm not sure I understand your answer.
I process the form input and check the validity of each item (passport still valid, age - over 18 etc.). If there is an invalid item I simply set the values of the text field to the visitors input and return the original form. My problem is displaying the correct value of a 'drop down menu' or 'radio button'. The visitors selection has to be selected on the returned form. I know I could hard code it but you guys usually have a simple way of doing this task.

Where is perldoc cgi?

Thanks
 
Correct, if you use CGI.pm to generate your form's you can use it to also set the defaults IN the form elements. Look here:

print $query->radio_group(-name=>'group_name',
-values=>['eenie','meenie','minie'],
-default=>'meenie',
-linebreak=>'true',
-labels=>\%labels);

That names (-name) the radio group as 'group_name'.

It sets the radio buttons 'eenie','meenie' and 'minie'.
It sets the default(-default) to 'meenie'.

It aligns them vertically

It then labels each option with the values in %labels


By changing the value of -default you can preset what appears. So, in this case you might set -default to whatever the user entered on the form they submitted from.
 
Thanks siberian - much clearer now although I'll have to put mi thinking head on to get it into the script.

Will give it a whirl and post my findings back here.

I'm using W98 on my home server so will find the docs there.

Once again thanks

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top