473,327 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Setting option value to session var

Hello,

I thought this should be easy, but... all I want to do is set the value
of this state drop-down based on a session var I'm getting back from a
redirect (from the processing page):
<%
tax = session("Tax")
city = session("City")
state = session("State")
%>

<select name="state">
<option value="">--Select--</option>
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>...
</select>

I can do it with the city field easy enough like this:
City : <input type="text" name="city" value="<%=city%>" size="8"
maxlength="15">

But this same technique doesn't work for the select box, it just keeps
returning to the
"--Select--".

Also, I'm trying to clear the fields that are populated with values
from the session vars like so:

<input type="Button" name="Reset" value="Clear"
onClick="clearFields();">

function clearFields()
{
document.form1.state.value == "--Select--";
document.form1.city.value == "test";
document.form1.tax.value == "";
}

But this doesn't work. Is there something special I'm supposed to do to
be able to clear session vars out of the form? I have the following
declared at the top of the page which I thougth should work: <%
Response.Expires = 0 %>

Any help greatly appreciated.

Thanks in advance,
KP

Mar 17 '06 #1
6 2411
Kermit Piper wrote on 18 mrt 2006 in
microsoft.public.inetserver.asp.general:
Hello,

I thought this should be easy, but... all I want to do is set the value
of this state drop-down based on a session var I'm getting back from a
redirect (from the processing page):
<%
tax = session("Tax")
city = session("City")
state = session("State")
if state="AL" then AL=" selected"
if state="AZ" then AZ=" selected"
etc
%>

<select name="state">
<option value="">--Select--</option>
<option value="AL">AL</option>
<option value="AL" <%=AL%>>AL</option>
<option value="AK">AK</option>
<option value="AZ" <%=AZ%>>AZ</option>
<option value="AZ">AZ</option>
etc

[I usually do this in a ASP 2 loops, having the states in a array]
<option value="AR">AR</option>
<option value="CA">CA</option>...
</select>


===========================

This is nice too, coloring the selected background serverside:

if state="AL" then AL=" selected style='background-color:yellow;'"
if state="AZ" then AZ=" selected style='background-color:yellow;'"
etc

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 18 '06 #2
Thank you Evertjan! I'll give it a try. How about clearing the form
field values, any ideas on that?

Mar 18 '06 #3
Kermit Piper wrote on 18 mrt 2006 in
microsoft.public.inetserver.asp.general:
Thank you Evertjan! I'll give it a try. How about clearing the form
field values, any ideas on that?


This is usenet, not email.
Please quote where you are responding on.

"form field values" are a clientside concept,
where ASP does not know about.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 18 '06 #4
Well that was condescending, useless and less than technically correct, all
at the same time -- looks like Evertjan gets a hat-trick, wtg.

There is of course a property of the Request object called Form, and IIRC it
provides server-side access to a collection of name/value pairs, that
correspond directly with elements of the posted form. So it would seem the
actual case is that ASP *does* know about forms, the fields they contain and
the values of those fields... imagine that!

Anyway, back to the OP's question, your session variables reside on the
server, so only code running on the server can clear them. This must
somehow involve a round-trip to the server (that would not ordinarily be
needed just to reset a form.) Maybe you could set a flag in a hidden input
when the form is reset, and use it to invoke a branch that clears your
session items the next time the form is posted? There are probably
thousands of ways it might be done, but the gist is, you must communicate
the need to clear the session data to server-side code, such as an ASP
script.
-Mark
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242...
Kermit Piper wrote on 18 mrt 2006 in
microsoft.public.inetserver.asp.general:
Thank you Evertjan! I'll give it a try. How about clearing the form
field values, any ideas on that?


This is usenet, not email.
Please quote where you are responding on.

"form field values" are a clientside concept,
where ASP does not know about.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Mar 22 '06 #5
Mark J. McGinty wrote:
Thank you Evertjan! I'll give it a try. How about clearing
the form field values, any ideas on that?
"form field values" are a clientside concept,
where ASP does not know about.


Well that was condescending, useless and less than
technically correct, all at the same time -- looks like
Evertjan gets a hat-trick, wtg.
There is of course a property of the Request object called
Form, and IIRC it provides server-side access to a
collection of name/value pairs, that correspond directly
with elements of the posted form.


There may be such a collection, but ASP still does not understand the
concept of form fields, much less "clearing" them. The request was
*obviously* about the client-side.
So it would seem the actual case is that ASP *does* know
about forms, the fields they contain and the values of those
fields... imagine that!


Actually, ASP does not. I can populate the Request.Form collection without
one using any of the various XMLHttpRequest objects. No forms are required
to do so.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Mar 22 '06 #6

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
Mark J. McGinty wrote:
Thank you Evertjan! I'll give it a try. How about clearing
the form field values, any ideas on that?

"form field values" are a clientside concept,
where ASP does not know about.
Well that was condescending, useless and less than
technically correct, all at the same time -- looks like
Evertjan gets a hat-trick, wtg.
There is of course a property of the Request object called
Form, and IIRC it provides server-side access to a
collection of name/value pairs, that correspond directly
with elements of the posted form.


There may be such a collection, but ASP still does not understand the
concept of form fields, much less "clearing" them. The request was
*obviously* about the client-side.


Specifically his question involved clearing the session variables, values of
which he is using when he constructs HTML as a response. Clearing session
variables is *obviously* a server-side affair. The fact that, even more
specifically, he is using the values of those session variables to emit
value
attributes for input elements that are children of the form element he is
generating *would* be completely irrelevant, if not for the way he phrased
his question.

Now before I continue my rhetoric I want to point out that I totally respect
your contributions to the Usenet, Dave, I see substantial technical accuracy
and depth in your posts; you seem both knowledgeable and objective. I have
no issues with you... and I'm sure we both have better things to do than
split hairs for this NG -- seriously! :-)

As for the OP, he might've phrased his question a little better, and if he
had quoted his earlier posts, the additional context might even have negated
your incentive to retort. Otoh, I read most of this thread in one sitting,
had all the context fresh in mind, and to me the imperfections of his
request were slight.

To me the question does not justify a response that's constructed like this:
"[diminutive statement of the obvious] [cursory glance at the 'letter' (as
opposed to the spirit) of the question] [brush-off in the form of a trite
analogistic reference to what ASP does or does not 'know'] [explicitly void
of anything even remotely helpful to OP]"

Effective translation: "I'm replying to your foolish attempt at a post to
this NG for
the following reasons only: a.) To spank you for your breach of
netiquette -- the importance of which transcends that of even the Net
itself, much less the topic at hand;
b.) To carelessly label your question as OT, having given it very little
thought, if any at all; c.) Just to say, 'piss on you', as I reassert my
standing as a know-nothing, industrial strength, reagent grade asshole,
99.7% pure, recognized by multiple cultures worldwide."

Personally, I object to replies that are 100% admonition. Some people like
to suggest other NGs -- that's fine, but I also think it's pointless to
merely inform an OP that there is a line between server and client sides.
Often it's clear that the line is a blur to the OP -- why not try to help
them to sharpen their view of that line? How are they better off posting to
a client-side oriented NG, at the same level of confusion with which they
posted to this one?

If it's clear enough that their confusion has server-side implications, so
what if they used client-side terminology to express it?

Anyway, I suspect that the core issue here is whether you (or anyone else)
is more offended by Evertjan's uniquely rude style and the utter lack of
anything useful in many of his posts, or by my vocal objections thereto. I
like to think I'm open minded, and I surely do not stay where I'm unwanted;
I will defer to a consensus. Anyone who thinks it would be more appropriate
for me to simply STFU about it, please speak freely. I will respect the
wishes of the group.

So it would seem the actual case is that ASP *does* know
about forms, the fields they contain and the values of those
fields... imagine that!


Actually, ASP does not. I can populate the Request.Form collection without
one using any of the various XMLHttpRequest objects. No forms are required
to do so.


Heh, why stop there? Why not construct the entire HTTP request by hand and
write sockets code to send it up to the server without all that messy API
and object crap? Hell, dust off MASM and drive yourself crazy! :-)

But are you suggesting that knowledge of the underlying protocol somehow
proves that Request.Form is entirely unrelated to a form in an HTML document
that was used to submit the "Request"? (I really wanted to avoid splitting
any more hairs but couldn't resist.)
-Mark

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms. Please do not
contact me directly or ask me to contact you directly for assistance. If
your question is worth asking, it's worth posting.


Mar 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bagsmode | last post by:
Hi, I'm trying to set a session cookie and then redirect, however I get the error: Status: 302 Moved Location: /index.cgi I thought I recall getting an error like this when I first tried...
9
by: netclectic | last post by:
I'm dynamically adding options to a select list in javascript and i need to be able to set the height of the option, but setting style.height has not effect, I also tried style.pixelHeight but no...
1
by: Scott Walters | last post by:
Hi, I have an asp.net webapp that uses some javascript in a hidden frame on the browser to poll the server every 30 seconds, using an http post. I also want my sessions to timeout in the...
0
by: news.microsoft.com | last post by:
I have a user control with four option buttons depending which option button is pressed I store a score into session object. On the load event of a control the session object is set to 0. There is...
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
3
by: Benny Ng | last post by:
Dear All, Now I met some performance problems in my application. Because according to our business. The size of some web forms are larger than 1xxx MB. So it takes a long time for user opening a...
6
by: metaperl | last post by:
I would like to check the setting of this variable in our MS-SQL 2000 database. Also, is there info on what the default value of this variable is?
1
flexsingh
by: flexsingh | last post by:
Hello there I have kinda got gotten myself into a sticky situation. I am trying to do something which seams too big to do in my head but I feel I kinda know how to do it. My problem is I have a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.