473,320 Members | 2,109 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,320 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 3288
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.