<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
On Error Resume Next
'*****************************************************************
'Variablendeklarationen
Dim sngresult
Dim strbtnlbladd
Dim strbtnlbldiv
Dim strbtnlblmult
Dim strbtnlblsubtrak
Dim stroperator
'*****************************************************************
'Variableninitialisierung
strbtnlbladd = "Addieren"
strbtnlbldiv = "Dividieren"
strbtnlblmult = "Multiplizieren"
strbtnlblsubtrak = "Subtrahieren"
%>
<html>
<head>
<title>ASP Formularverarbeitung: Formularverarbeitung auf einer ASP-Seite
</title>
</head>
<body>
<h1>Grundrechenoperationen
</h1>
<form action="uebung4_1form.asp" method="post">
<input type="Text" name="frmfldtext1" value="<%=Request.Form("frmfldtext1")%>" />
<input type="text" name="frmfldtext2" value="<%=Request.Form("frmfldtext2")%>" /><br />
<input type="submit" value="<%=strbtnlbladd%>" name="btnsubmit">
<input type="submit" value="<%=strbtnlblsubtrak%>" name="btnsubmit">
<input type="submit" value="<%=strbtnlblmult%>" name="btnsubmit">
<input type="submit" value="<%=strbtnlbldiv%>" name="btnsubmit">
</form>
<%
select case Request.Form("btnsubmit")
case strbtnlbladd
sngresult = 0 + Request.Form("frmfldtext1") + Request.Form("frmfldtext2")
stroperator = " + "
case strbtnlblsubtrak
sngresult = Request.Form("frmfldtext1") - Request.Form("frmfldtext2")
stroperator = " - "
case strbtnlblmult
sngresult = Request.Form("frmfldtext1") * Request.Form("frmfldtext2")
stroperator = " * "
case strbtnlbldiv
'Auf eine Dezimalstelle formatiert
sngresult = _
FormatNumber(Request.Form("frmfldtext1") / Request.Form("frmfldtext2"),1)
stroperator = " / "
case else
sngresult = 0
end select
'Resultat nur anzeigen, wenn Formular abgeschickt
if Request.Form("btnsubmit") <> "" then
Response.Write("<p>" & Request.Form("frmfldtext1") & _
stroperator & Request.Form("frmfldtext2") & " = " & _
sngresult & "</p>" & vbCrLf)
end if
%>
<!--#include virtual="asppages/silvi/_include/inchtmlnachspann.asp" -->
</body>
</html>
Demo: uebungen/uebung4_1form.asp
Letzter Update:
26.12.2021 16:48
Zurück zur
Liste mit ASP-Übungen auf
www.ecotronics.ch