Assign a value to a Session variable from an Script

M

Mirovk

Hi,

I have a session variable wich value arrives from a previous .asp but
in my actual page I need to modify it based upon a selected value from
a radio button.

I will try to figure out for better understanding:

page1.asp ---> session("PaymentMethod")
page2.asp ---> Depending on the radio button selected the payment
method could be (check, transfer, creditcard) and this value must be
assigned to "PaymentMethod" session variable for further processing.

1.- In my form I created the hidden value:
<input type="Hidden" name="PaymentMethod" value="" id="PaymentMethod"
/>

2.- Radio buttons at the form

<input type="radio" checked name="btn_tipo_pago" value="1" >&nbsp;1.
Payment: Check</td>

<input type="radio" checked name="btn_tipo_pago" value="2" >&nbsp;1.
Payment: Transfer</td>

<input type="radio" checked name="btn_tipo_pago" value="3" >&nbsp;1.
Payment: Creditcard</td>

3.- Script to Identify wich button was selected as soon as the continue
button is pressed:
<SCRIPT FOR="continue" EVENT="onclick" LANGUAGE="VBScript">
Dim oElement, oElements, oRadio
Dim sValue
set oElements = Document.frmdir.Elements
for each oElement in oElements
if oElement.Type= "radio" and oElement.Checked = True then
set oRadio = oElement
Exit for
End if
next
sValue = oRadio.value

4.- My questions are:
1.- From point (3) how may assign the sValue to my session variable
"Payment Method"

2.- How may I obtain and display through an alert the contents of
another session variable.


Thanks for your cooperation....
 
A

Aaron Bertrand [SQL Server MVP]

1.- From point (3) how may assign the sValue to my session variable
"Payment Method"

Is there really any point in setting the session variable while you're still
in client-side script? Think about it, you can't use it yet in any ASP
code, because all you have is static HTML code and JavaScript sitting on the
client until they proceed to the next page... presumably, by submitting a
form, which could include their payment method, and which the processing
page could then save to a session variable.

Sure, there are kludges, but I fail to see what you gain by using them.
http://classicasp.aspfaq.com/general/how-do-i-set-session-variables-from-client-side-script.html
2.- How may I obtain and display through an alert the contents of
another session variable.

<script>
alert("<%=Session("OtherSessionVariableName")%>");
</script>
 

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,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top