<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
'On Error Resume Next
Dim blnfirst, strbtnlblsubmit, strfield, strvalue
strbtnlblsubmit = "Abschicken"
Function funvarif(ByVal blncondition, ByVal varthenpart, ByVal varelsepart)
If blncondition Then
funvarif = varthenpart
Else
funvarif = varelsepart
End if
End Function
%>
<!--#include virtual="asppages/silvi/_include/preheader.inc" -->
<html>
<head>
<title>ASP Formularverarbeitung: Collection mit For Each abarbeiten
</title>
<!--#include virtual="asppages/silvi/_include/header.inc" -->
</head>
<body>
<%
If Request.Form("btnsubmit") = strbtnlblsubmit Then
Response.Write("<h2>Ihre Eingaben</h2><table border=""1"">" & vbCRLf)
For Each strfield In Request.Form
Response.Write("<tr>" & vbCRLf)
Response.Write("<td valign=""top"">" & vbCRLf)
Response.Write(strfield & "<br />")
Response.Write("</td>" & vbCRLf)
Response.Write("<td valign=""top"">" & vbCRLf)
blnfirst = true
For Each strvalue In Request.Form(strfield)
if not blnfirst then
Response.Write("<br />")
else
blnfirst = false
end if
Response.Write(strvalue)
Next
Response.Write("</td>" & vbCRLf)
Response.Write("</tr>" & vbCRLf)
Next
Response.Write("</table>" & vbCRLf)
End If
%>
<h2>Formular
</h2>
<form method="post" action="030formularforeach.asp">
<p>Text
<input type="text" name="frmfldtext" size="20" value="<%
=Request.Form("frmfldtext")%>" /></p>
<p>Dropdown mit Mehrfachauswahl
</p>
<p>
<select size="3" name="frmflddropdown" multiple="">
<option value="1" <%
Response.Write(funvarif(InStr(Request.Form("frmflddropdown"),"1")>0,_
" selected=""""",""))%>>Auswahl 1
</option>
<option value="2" <%
Response.Write(funvarif(InStr(Request.Form("frmflddropdown"),"2")>0,_
" selected=""""",""))%>>Auswahl 2
</option>
<option value="3" <%
Response.Write(funvarif(InStr(Request.Form("frmflddropdown"),"3")>0,_
" selected=""""",""))%>>Auswahl 3
</option>
</select>
</p>
<p>Dropdown ohne Mehrfachauswahl
</p>
<p>
<select size="1" name="frmflddropdownohne">
<option value="1" <%
Response.Write(funvarif(Request.Form("frmflddropdownohne") = 1,_
" selected=""""",""))%>>Auswahl 1
</option>
<option value="2" <%
Response.Write(funvarif(Request.Form("frmflddropdownohne") = 2,_
" selected=""""",""))%>>Auswahl 2
</option>
<option value="3" <%
Response.Write(funvarif(Request.Form("frmflddropdownohne") = 3,_
" selected=""""",""))%>>Auswahl 3
</option>
</select>
</p>
<p><input type="radio" name="frmfldoption" value="A" / <%
Response.Write(funvarif(Request.Form("frmfldoption") = "A",_
" checked=""""",""))%> />A
<input type="radio" name="frmfldoption" value="B" / <%
Response.Write(funvarif(Request.Form("frmfldoption") = "B",_
" checked=""""",""))%> />B
</p>
<p>
<input type="checkbox" name="frmfldcheckbox" value="angekreuzt" / <%
Response.Write(funvarif(Request.Form("frmfldcheckbox") = "angekreuzt",_
" checked=""""",""))%> />Kontrollkästchen
</p>
<p><input type="submit" name="btnsubmit" value="<%=strbtnlblsubmit%>" /></p>
</form>
<!--#include virtual="asppages/silvi/_include/inchtmlnachspann.asp" -->
</body>
</html>
Demo: beispiele/030formularforeach.asp
Letzter Update:
26.12.2021 16:48
Zurück zur
Liste mit ASP-Beispielen auf
www.ecotronics.ch