How to maintain session state using hidden fields?

Z

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);
}
}
}

the textboxes in html:

Code:
<input type="text" name="hEmpID" value="">
<input type="text" name="hCrystalRadio" value="">
<input type="text" name="hPeriod" value="">

Thanks.
 
R

Roland Hall

zwieback89 said:
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);
}
}
}

the textboxes in html:

Code:
<input type="text" name="hEmpID" value="">
<input type="text" name="hCrystalRadio" value="">
<input type="text" name="hPeriod" value="">

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 "<script type=""text/javascript"">"
prt "function ..."
prt "..."
prt "</script>"

Not this:

%>
<script type="text/javascript">
function ...
....
</script>

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.

HTH...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top