473,411 Members | 1,995 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,411 software developers and data experts.

Dynamically diplaying form fields after selectuing data from drop down

Chittaranjan
Hi All,

I have a problem and hope I can get the better solution from here.

I have a form written in HTML and I need to write that in perl so the main problem I am facing is that I need to generate some fields according the data I will select from the drop down list so basically I have drop down list which will ask for the number of students information I want to enter and after selecting a value from the number of students drop down it suppose to display that much set of First name, Last name, Phone number etc. So how can I post back the data to the same form in PERL script I can't able to know. I know we can do in Java but for PERL I do not know. So please help me I will be grateful to you all. I will be waiting for the replies.

Thanks,
Chittaranjan :)
Nov 20 '06 #1
2 3296
GunnarH
83
Basically you can do something like this:
Expand|Select|Wrap|Line Numbers
  1. use CGI;
  2. my $cgi = CGI->new;
  3.  
  4. print $cgi->header;
  5. print qq|<form method="post">\n|;
  6.  
  7. if ( $cgi->param('number') ) {
  8.  
  9.     for ( 1 .. $cgi->param('number') ) {
  10.         print <<REC;
  11. <p>First name $_:<br><input name="first_$_">
  12. <p>Last name $_:<br><input name="last_$_">
  13. <p>Phone number $_:<br><input name="phone_$_">
  14. <hr>
  15. REC
  16.     }
  17.  
  18. } else {
  19.  
  20.     print <<NUM;
  21. <p>Select number of records:<br>
  22. <select name="number">
  23. <option selected>1</option>
  24. <option>2</option>
  25. <option>3</option>
  26. <option>4</option>
  27. <option>5</option>
  28. </select>
  29. NUM
  30.  
  31. }
  32.  
  33. print qq|<p><input type="submit">\n</form>\n|;
Nov 20 '06 #2
Basically you can do something like this:
Expand|Select|Wrap|Line Numbers
  1. use CGI;
  2. my $cgi = CGI->new;
  3.  
  4. print $cgi->header;
  5. print qq|<form method="post">\n|;
  6.  
  7. if ( $cgi->param('number') ) {
  8.  
  9.     for ( 1 .. $cgi->param('number') ) {
  10.         print <<REC;
  11. <p>First name $_:<br><input name="first_$_">
  12. <p>Last name $_:<br><input name="last_$_">
  13. <p>Phone number $_:<br><input name="phone_$_">
  14. <hr>
  15. REC
  16.     }
  17.  
  18. } else {
  19.  
  20.     print <<NUM;
  21. <p>Select number of records:<br>
  22. <select name="number">
  23. <option selected>1</option>
  24. <option>2</option>
  25. <option>3</option>
  26. <option>4</option>
  27. <option>5</option>
  28. </select>
  29. NUM
  30.  
  31. }
  32.  
  33. print qq|<p><input type="submit">\n</form>\n|;
Thanks GunnarH,

It works great. you are unbelievable, nice way to the solution.

Thanks again For your great help,
Chittaranjan :)
Nov 21 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Flos | last post by:
Hello! (sorry for my bad english) the following problem: i have i site where one must enter data which is safed in a database. There are also drop down lists, which values are database...
0
by: Steve Edwards | last post by:
I am working on a site where I need to create forms to both add and edit information for a group of products. I would like to use the same form for both adding new and edit data for existing...
3
by: julian | last post by:
hi I was wondering if anyone can help me out on this.... I have dynamcally populated a drop down menu with data from an access database using ASP. The values seem fine, however when i pass...
6
by: skgolden | last post by:
My husband and I own a small temporary labor company and deal with 4 major clients (A,B,C & D), each of which has about 2 dozen units in our tristate area that we deal with (ie, Company A, units...
3
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include...
3
by: Greg Scharlemann | last post by:
I'm not sure the best way to accomplish this... my hunch is with javascript, but I'm not sure if using server side code (PHP) would be easier. I'm adding people to a database. People have a...
4
by: Greg Scharlemann | last post by:
I'm trying to setup a dyamic dropdown list that displays a number of text fields based on the selected number in the dropdown. The problem I am running into is capturing the data already entered...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.