Pelle
02-15-2005, 06:01 PM
I submit two different forms with one hidden value each with no action specified (the form is
submitted to itself). As soon as a form is submitted the form number (1 or 2) is displayed in the select
box. I use a session variable and an array to remember and expand the select box between each submit. The local
array is re-dimensioned frequently to make room for yet another record.
My big problem is how I can show the sub content (the radio button's values) when I click the button "show subcontent".
I want to be redirected to another URL, for example "showselect.asp" and the results should preferrably (or any other way) be
displayed like this:
Form 1
Sub1
Form 1
Sub2
Form 2
Sub4
Of course the display should depend on which radiobutton has been checked when the each form was submitted.
I do not want the same kind of display in the select box with sub1 etc.. There I prefer just the "Form 1"
or "Form 2" information. It is when I click the show subcontent the details should be shown.
Can I achieve this by using a multidimensional array? How? Any other suggestion?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim hiddenvalue
Dim radiovalue
Dim FreeSpot
Dim storage
' Retrieve form values (1 hidden value and 1 from a radio button)
hiddenvalue = Request.Form("hidden")
' I don't know how to treat the radiovalue here...
radiovalue = Request.Form("radiogroup")
' Check if an array is already stored in a session variable. If not, create an array else retrieve variable.
IF NOT isArray( Session( "storage" ) ) THEN
Dim MyArray(0)
MyArray(0) = hiddenvalue
ELSE
MyArray = Session( "storage" )
' Here the array is enlarged to make space for a new value from the form.
x = uBound(MyArray)
x = x + 1
ReDim Preserve MyArray(x)
For i = 0 to uBound(MyArray)
' Checks for an empty position in the array to store the retrieved hidden value.
if FreeSpot = False then
if MyArray(i) = "" then
' When the empty spot has been found, the value is stored in the array.
MyArray(i) = hiddenvalue
FreeSpot = True
end if
end if
Next
END IF
%>
<html>
<head>
<title>Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="">
<p>Form 1 </p>
<input name="hidden" type="hidden" id="hidden1" value="form1">
<input type="radio" name="radiogroup" value="sub1" checked>
subcontent 1 <br>
<input type="radio" name="radiogroup" value="sub2">
subcontent 2 <br>
<p>
<input name="Submit1" type="submit" value="Submit to selectbox">
</p>
</form>
<form name="form2" method="post" action="">
<p>Form 2</p>
<p>
<input name="hidden" type="hidden" value="form2">
</p>
<input type="radio" name="radiogroup" value="sub3" checked>
subcontent 3 <br>
<input type="radio" name="radiogroup" value="sub4">
subcontent 4 <br>
<p>
<input name="Submit2" type="submit" value="Submit to selectbox">
</p>
</form>
<select name="menu1">
<%
'load the values stored in the array into the select box.
for i = 0 to UBound(MyArray)%>
<option><%=MyArray(i)%></option>
<%next%>
</select>
<%
' When this button is clicked I want to display all content of the ' select box. That is not only the "form1" and "form2" but also which ' sub value (1-4) is connected to which form. For example First there ' is "Form" 1 with "sub1" as subcontent. On the next spot in the ' select box we may find "Form 1" again, but this time with "sub2" as ' subcontent. How is that done?
%>
<input type="submit" name="Submit" value="Show subcontent">
<%
'Update the session variable with the current array records
Session( "storage" ) = MyArray
%>
</body>
</html>
submitted to itself). As soon as a form is submitted the form number (1 or 2) is displayed in the select
box. I use a session variable and an array to remember and expand the select box between each submit. The local
array is re-dimensioned frequently to make room for yet another record.
My big problem is how I can show the sub content (the radio button's values) when I click the button "show subcontent".
I want to be redirected to another URL, for example "showselect.asp" and the results should preferrably (or any other way) be
displayed like this:
Form 1
Sub1
Form 1
Sub2
Form 2
Sub4
Of course the display should depend on which radiobutton has been checked when the each form was submitted.
I do not want the same kind of display in the select box with sub1 etc.. There I prefer just the "Form 1"
or "Form 2" information. It is when I click the show subcontent the details should be shown.
Can I achieve this by using a multidimensional array? How? Any other suggestion?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim hiddenvalue
Dim radiovalue
Dim FreeSpot
Dim storage
' Retrieve form values (1 hidden value and 1 from a radio button)
hiddenvalue = Request.Form("hidden")
' I don't know how to treat the radiovalue here...
radiovalue = Request.Form("radiogroup")
' Check if an array is already stored in a session variable. If not, create an array else retrieve variable.
IF NOT isArray( Session( "storage" ) ) THEN
Dim MyArray(0)
MyArray(0) = hiddenvalue
ELSE
MyArray = Session( "storage" )
' Here the array is enlarged to make space for a new value from the form.
x = uBound(MyArray)
x = x + 1
ReDim Preserve MyArray(x)
For i = 0 to uBound(MyArray)
' Checks for an empty position in the array to store the retrieved hidden value.
if FreeSpot = False then
if MyArray(i) = "" then
' When the empty spot has been found, the value is stored in the array.
MyArray(i) = hiddenvalue
FreeSpot = True
end if
end if
Next
END IF
%>
<html>
<head>
<title>Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="">
<p>Form 1 </p>
<input name="hidden" type="hidden" id="hidden1" value="form1">
<input type="radio" name="radiogroup" value="sub1" checked>
subcontent 1 <br>
<input type="radio" name="radiogroup" value="sub2">
subcontent 2 <br>
<p>
<input name="Submit1" type="submit" value="Submit to selectbox">
</p>
</form>
<form name="form2" method="post" action="">
<p>Form 2</p>
<p>
<input name="hidden" type="hidden" value="form2">
</p>
<input type="radio" name="radiogroup" value="sub3" checked>
subcontent 3 <br>
<input type="radio" name="radiogroup" value="sub4">
subcontent 4 <br>
<p>
<input name="Submit2" type="submit" value="Submit to selectbox">
</p>
</form>
<select name="menu1">
<%
'load the values stored in the array into the select box.
for i = 0 to UBound(MyArray)%>
<option><%=MyArray(i)%></option>
<%next%>
</select>
<%
' When this button is clicked I want to display all content of the ' select box. That is not only the "form1" and "form2" but also which ' sub value (1-4) is connected to which form. For example First there ' is "Form" 1 with "sub1" as subcontent. On the next spot in the ' select box we may find "Form 1" again, but this time with "sub2" as ' subcontent. How is that done?
%>
<input type="submit" name="Submit" value="Show subcontent">
<%
'Update the session variable with the current array records
Session( "storage" ) = MyArray
%>
</body>
</html>