|
<!--#include file="inc/EasyForm.asp" -->
<%
EF.DimVar "email","text"
EF.DimVar "Password","password"
EF.DimVar "newarticles","checkbox"
EF.DimVar "updatedarticles","checkbox"
EF.DimVar "role","select"
EF.DimVar "platform","select"
EF.DimVar "mailformat","radio"
EF.DimVar "notes","textarea"
EF.DimVar "SaveForm","button"
EF.DimVar "formcheck","literal"
EF.DimVar "mailcheck","literal"
EF.DimVar "rolecheck","literal"
'---------------------------------------------------
Dim Validated
EF.init
sub EF_onLoad()
if EF.IsFirstLoad then
email.value = "your mail here"
mailformat.value = "HTML"
platform.value = "WIN,NET"
newarticles.value = "1"
end if
Validated = false
end sub
sub SaveForm_onclick()
Validated = true
formcheck.value = "Data saved!"
'trivial mail check
if instr(email.value,"@")=0 then
mailcheck.value="<span class=Error>Please insert an email</span>"
Validated = false
else
mailcheck.value=""
end if
'Role check
if role.value = "noselection" then
rolecheck.value = "<span class=Error>Please choose a role</span"
Validated = false
else
rolecheck.value = ""
end if
if not Validated then
formcheck.value = "<span class=Error>Some incorrect data</span>"
end if
end sub
%>
<html>
<head>
<style>
body,td, select, input {
font-family:tahoma,verdana;
font-size:12px;
}
.comment { color:green; }
.Error { color:red; }
</style>
</head>
<body>
<br />
<div class=comment>
In this example it is shown how to work with the submitted data.
First of all we replaced the classic submit button of the previous example with an EasyForm button.
That is, we declare a "button" EasyForm variable, named <i>SaveForm</i> and we attach the html button to it.
In this way the button click produces a postback and EasyForm automatically call a sub named <i>SaveForm_onclick</i>.
This sub performs some data validation and if necessary write a validation message using literals.
<br />
<i>Literals</i> are special EasyForm variables that not need to be attached to a control.
Literals are similar to classic variables, but they are able to remember their value in subsequent form postbacks, using encrypted hidden fields.
</div>
<br />
<%=formcheck.value%>
<%if not Validated then %>
<form method="post">
<table>
<tr>
<td valign=top align=right>
<span>Email</span> <br /><br />
<span>Password</span> <br /><br /><br />
<span>Topics</span> <br /><br /><br />
<span>Role</span> <br /><br /><br />
<span>Platform</span> <br /><br /><br /><br />
<span>Email format</span> <br /><br /><br /><br /><br />
<span>Notes</span> <br />
</td>
<td valign=top>
<input type="text" <%Email.Bind%> /><%=mailcheck.value%> <br />
<input type="password" <%Password.Bind%> /> <br /><br />
<input type="checkbox" <%newarticles.Bind%> />New Articles <br />
<input type="checkbox" <%updatedarticles.Bind%> />Updated Articles <br /><br />
<select <%role.Bind%> >
<option <%role.AddOption "noselection" %> >Select role...</option>
<option <%role.AddOption "CS"%>>C# developer</option>
<option <%role.AddOption "CPP"%>>C++ developer</option>
<option <%role.AddOption "WEB"%>>Web developer</option>
</select> <%=rolecheck.value%>
<br /><br />
<select <%platform.bind%> size=3 multiple>
<option <%platform.AddOption "WIN"%>>Windows</option>
<option <%platform.AddOption "NET"%>>.Net</option>
<option <%platform.AddOption "MOB"%>>Mobile</option>
</select>
<br /><br />
<input type=radio <%mailformat.AddOption "HTML"%>>Html <br />
<input type=radio <%mailformat.AddOption "TEXT"%>>Text <br /><br />
<textarea cols=20 rows=5 <%Notes.Bind%>><%=Notes.value%></textarea> <br />
<input type=button value="Save" <%SaveForm.Bind %> />
</td>
</tr>
</table>
<%EF.EndForm%>
</form>
<%end if%>
<a href="sample2.asp">reset</a>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a graduate in Computer Science.
I work with Metatrader MQL4,MQL5 / C# / Asp.Net / Windows Forms / SQL Server / Access / VBA / HTML / CSS / Javascript / classic C/C++.
I also like writing songs and playing around with my band
Diversamente Rossi.
This is the video of the song
Un'altra estate from the album
L'immobile disegno.
"Short code, good code"