Persisting Values

J

James Baker

I have a form that has a dropdown list that will cause a post to the same
page when it's changed. The problem I'm running into is that all of the
controls reset to their default values (obviously expected behavior).
What's the recommended/best way to persist these values through the post
process? I know I could set them to the request.form values of themselves,
so to speak...but I didn't know if there was a simpler/more efficient way.

Thanks,
James
 
D

David C. Holley

The only solution that I found was to write the VALUE using
value=<%response.write request("userName")%>. For the list boxes, I
chopped of the HTML into two segments such as...

<%if request("airline") <> "" then%>
<option value="<%response.write request("airline")%>"<%response.write
request("airline")</option>
<%else if%>
<option value="">---Select Airline---</option>
<%end if%>
[rest of the option's here]

This puts the selected option at the top of the list.

I STRONGLY recommend avoiding the specifying which options is SELECTED.
I had mutliple problems with this when I was testing across different
browsers with and without the a particular option selected. Writing the
value from the request as the first option achieves the same effect as
if it were written using SELECTED.

David H
 
J

James Baker

Thanks for the reply. Only issue I have with that 'selected' issue is, I
have a multi-select box. Am I SOL?

David C. Holley said:
The only solution that I found was to write the VALUE using
value=<%response.write request("userName")%>. For the list boxes, I
chopped of the HTML into two segments such as...

<%if request("airline") <> "" then%>
<option value="<%response.write request("airline")%>"<%response.write
request("airline")</option>
<%else if%>
<option value="">---Select Airline---</option>
<%end if%>
[rest of the option's here]

This puts the selected option at the top of the list.

I STRONGLY recommend avoiding the specifying which options is SELECTED.
I had mutliple problems with this when I was testing across different
browsers with and without the a particular option selected. Writing the
value from the request as the first option achieves the same effect as
if it were written using SELECTED.

David H


James said:
I have a form that has a dropdown list that will cause a post to the same
page when it's changed. The problem I'm running into is that all of the
controls reset to their default values (obviously expected behavior).
What's the recommended/best way to persist these values through the post
process? I know I could set them to the request.form values of themselves,
so to speak...but I didn't know if there was a simpler/more efficient way.

Thanks,
James
 
B

Bullschmidt

<<
I have a form that has a dropdown list that will cause a post to the
same page when it's changed. The problem I'm running into is that all of
the controls reset to their default values (obviously expected
behavior).
What's the recommended/best way to persist these values through the post
process? I know I could set them to the request.form values of
themselves, so to speak...but I didn't know if there was a simpler/more
efficient way.
Perhaps this may hopefully give some ideas, it's got a downloadable
sample, and does retain values after the post back:

ASP Design Tips - Dependent Listboxes
http://www.bullschmidt.com/devtip-dependentlistboxes.asp

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

David Holley

Well if you're using a multiple-select box, the solution is simple -
DON'T! (It only hurts when I bend it like this...)

I'm clueless at that point, since I haven't encountered that problem
yet.

David H

www.gatewayorlando.com

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

David C. Holley

Hmmmm....but you could try something where you kind of 'fool' your
visitor. When the page resubmits to itself, if there's an option in the
list box selected you could write a list box populated ONLY with
selected values - each with the SELECTED spec in the <option> tag. Then
provide the user when a CHANGE or CLEAR button that resubmits back to
the page, but with a querystring value that tells the page to draw the
list box with ALL possible values.

EVENT: Initial Page Load
ACTION: Populate list box with all possible values

EVENT: Self-submit - no value in the querystring or no values selected
ACTION: Populate list box with all possible values

EVENT: Self-submit - no value in the querystring, but values selected
ACTION: Populate list box with values from the request with each one
having the SELECT specified
Show the CHANGE/CLEAR button

EVENT: Self-submit - value in the querystring
ACTION: Populate list box with all possible values

I'm a bit frazzeled from work but at least that might get you going in
the right direction.

David H

James said:
Thanks for the reply. Only issue I have with that 'selected' issue is, I
have a multi-select box. Am I SOL?

The only solution that I found was to write the VALUE using
value=<%response.write request("userName")%>. For the list boxes, I
chopped of the HTML into two segments such as...

<%if request("airline") <> "" then%>
<option value="<%response.write request("airline")%>"<%response.write
request("airline")</option>
<%else if%>
<option value="">---Select Airline---</option>
<%end if%>
[rest of the option's here]

This puts the selected option at the top of the list.

I STRONGLY recommend avoiding the specifying which options is SELECTED.
I had mutliple problems with this when I was testing across different
browsers with and without the a particular option selected. Writing the
value from the request as the first option achieves the same effect as
if it were written using SELECTED.

David H


James said:
I have a form that has a dropdown list that will cause a post to the
same
page when it's changed. The problem I'm running into is that all of the
controls reset to their default values (obviously expected behavior).
What's the recommended/best way to persist these values through the post
process? I know I could set them to the request.form values of
themselves,
so to speak...but I didn't know if there was a simpler/more efficient
way.
Thanks,
James
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top