Skip to content

Commit cb9d863

Browse files
Add files via upload
1 parent 3ea35ee commit cb9d863

File tree

2 files changed

+1210
-0
lines changed

2 files changed

+1210
-0
lines changed

perl/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## How to work with WebForms Core in Perl
2+
3+
To use WebForms Core, first copy the WebForms class file in this directory to your project. Then create a new View file similar to the one below.
4+
5+
```perl
6+
#!/usr/bin/perl
7+
use strict;
8+
use warnings;
9+
use CGI;
10+
use lib '.'; # Add the current directory to @INC
11+
use WebForms;
12+
13+
my $cgi = CGI->new;
14+
15+
# Check if the form is submitted
16+
if ($cgi->param('btn_SetBodyValue')) {
17+
my $name = $cgi->param('txt_Name');
18+
my $backgroundColor = $cgi->param('txt_BackgroundColor');
19+
my $fontSize = $cgi->param('txt_FontSize');
20+
21+
my $form = WebForms->new;
22+
23+
$form->SetFontSize(InputPlace::Tag('form'), "$fontSize" . "px");
24+
$form->SetBackgroundColor(InputPlace::Tag('form'), $backgroundColor);
25+
$form->SetDisabled(InputPlace::Name('btn_SetBodyValue'), 1);
26+
27+
$form->AddTag(InputPlace::Tag('form'), 'h3');
28+
$form->SetText(InputPlace::Tag('h3'), "Welcome $name!");
29+
30+
print $cgi->header('text/plain');
31+
print $form->Response();
32+
exit;
33+
}
34+
35+
# Render the form if not submitted
36+
print $cgi->header('text/html');
37+
print <<"HTML";
38+
<!DOCTYPE html>
39+
<html>
40+
<head>
41+
<title>Using WebForms Core in Perl</title>
42+
<script type="text/javascript" src="/script/web-forms.js"></script>
43+
</head>
44+
<body>
45+
<form method="post" action="/">
46+
<label for="txt_Name">Your Name</label>
47+
<input name="txt_Name" id="txt_Name" type="text" />
48+
<br>
49+
<label for="txt_FontSize">Set Font Size</label>
50+
<input name="txt_FontSize" id="txt_FontSize" type="number" value="16" min="10" max="36" />
51+
<br>
52+
<label for="txt_BackgroundColor">Set Background Color</label>
53+
<input name="txt_BackgroundColor" id="txt_BackgroundColor" type="text" />
54+
<br>
55+
<input name="btn_SetBodyValue" type="submit" value="Click to send data" />
56+
</form>
57+
</body>
58+
</html>
59+
HTML
60+
```
61+
62+
In the upper part of the View file, it is first checked whether the submit button has been clicked or not, if it has been clicked, an instance of the WebForms class is created, then the WebForms methods are called, and then the response method is printed on the screen, and other parts Views are not displayed.
63+
Please note that if the submit button is not clicked (initial request), the view page will be displayed completely for the requester.
64+
65+
As you can see, the WebFormsJS script has been added in the header section of the View file above.
66+
67+
The latest version of the WebFormsJS script is available through the link below.
68+
69+
https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js

0 commit comments

Comments
 (0)