How to maintain session state using hidden fields?
How to maintain session state using hidden fields?
am 02.02.2007 00:27:27 von zwieback89
Hi,
I have a org tree with hierarchical display of employees built using
classic asp and vbscript.
I also have list of radio buttons for report names.
I have 1 select box with dates in it.
Then I click on the submit button to view the reports in Crystal. But
when I come back, my org tree is now collapased
I store the employee clicked (radio button), report clicked (radio
button), date (drop down) in hidden fields on submit of the form.
Now when I come back, how can I use these hidden fields to store the
page state?
Please advise what other information you may need.
javascript that populates the text boxes.
[code]
function ValidateData(f) {
// Check to make sure Reporting Period is selected.
if (f.period.value == "Select") {
alert("Select a Reporting Period");
f.period.focus();
return false;
}
//Check to make sure a report is selected.
// validate myradiobuttons
myOption = -1;
for (i=f.crystalradio.length-1; i > -1; i--) {
if (f.crystalradio[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("You must select a report to view");
return false;
}
var jPeriod = f.period.value;
f.hPeriod.value = jPeriod;
alert(jPeriod);
for (i=f.empid.length-1; i>-1; i--)
{
if (f.empid[i].checked)
{
f.hEmpID.value = f.empid[i].value;
alert(f.hEmpID.value);
}
}
for (i=f.crystalradio.length-1;i>-1;i--)
{
if (f.crystalradio[i].checked)
{
f.hCrystalRadio.value = f.crystalradio[i].value;
alert(f.hCrystalRadio.value);
}
}
}
[/code]
the textboxes in html:
[code]
[/code]
Thanks.
Re: How to maintain session state using hidden fields?
am 02.02.2007 06:28:11 von Roland Hall
"zwieback89" wrote in message
news:1170372447.773539.165540@j27g2000cwj.googlegroups.com.. .
> Hi,
>
> I have a org tree with hierarchical display of employees built using
> classic asp and vbscript.
>
> I also have list of radio buttons for report names.
>
> I have 1 select box with dates in it.
>
> Then I click on the submit button to view the reports in Crystal. But
> when I come back, my org tree is now collapased
>
> I store the employee clicked (radio button), report clicked (radio
> button), date (drop down) in hidden fields on submit of the form.
>
> Now when I come back, how can I use these hidden fields to store the
> page state?
>
> Please advise what other information you may need.
>
> javascript that populates the text boxes.
> [code]
> function ValidateData(f) {
>
> // Check to make sure Reporting Period is selected.
> if (f.period.value == "Select") {
> alert("Select a Reporting Period");
> f.period.focus();
> return false;
> }
>
> //Check to make sure a report is selected.
> // validate myradiobuttons
> myOption = -1;
> for (i=f.crystalradio.length-1; i > -1; i--) {
> if (f.crystalradio[i].checked) {
> myOption = i;
> }
> }
> if (myOption == -1) {
> alert("You must select a report to view");
> return false;
> }
>
> var jPeriod = f.period.value;
> f.hPeriod.value = jPeriod;
> alert(jPeriod);
>
> for (i=f.empid.length-1; i>-1; i--)
> {
> if (f.empid[i].checked)
> {
> f.hEmpID.value = f.empid[i].value;
> alert(f.hEmpID.value);
> }
> }
>
> for (i=f.crystalradio.length-1;i>-1;i--)
> {
> if (f.crystalradio[i].checked)
> {
> f.hCrystalRadio.value = f.crystalradio[i].value;
> alert(f.hCrystalRadio.value);
> }
> }
> }
> [/code]
>
> the textboxes in html:
>
> [code]
>
>
>
> [/code]
>
> Thanks.
>
Classic ASP is not stateful. You will need to set the values back after
posting. The way I accomplish this is to use ASP to write my client-side
code.
Ex.
This:
sub prt(str)
Response.Write str & vbCrLf
end sub
prt ""
Not this:
%>
This way I can fill in server side values that will get passed to the
client.
You can always mix server script within but I find it to be slower and more
difficult to read.