Click to See Complete Forum and Search --> : how to pass a variable to more than one form


andrewchai
04-01-2005, 02:46 AM
how do i to pass a variable to more than one form without using the request.form() and cookies or session.

buntine
04-01-2005, 02:51 AM
.... How do you want to send it then? The only other option I can think of is the QueryString. Unless you wanted to temporarily store the variable on the server via the means of a database or text-based file.

andrewchai
04-01-2005, 03:11 AM
the problem that i face : i unable to retrieve the data from the javascript cookies in the previous page so i unable to save the data.

for example:
<%
dim a

a = response.write("<script>document.cookies</script>")

str_sql ="Insert Into ltrans (staffid, no_days, year_ent, balance) Values " _
& "('"&cQuote(request("id"))&"', " _
& "'"&cQuote(request("days"))&"', " _
& "'"&cQuote(request("year_ent"))&"', " _
& "& a &)"
conS.Execute str_sql
%>

buntine
04-01-2005, 04:09 AM
Get the cookie from the server. ASP can make and retrieve cookies.

Dim a
a = Request.Cookies("nameOfCookie")

It seems you still don't understand the differance between server-side and client-side programming. The a variable will only contain the string you assigned to it. I suggest you read up in the subject.

Regards.

andrewchai
04-01-2005, 05:05 AM
can you help me to check with this :
please !

page: calculate.asp
<script>
days = days;

document.getElementById("days").value = days

var yr_ent;
var old_balance;
var balance;


old_balance = document.getElementById("balance");
balance = old_balance.value - days;

document.getElementById("balance").value = balance;
document.cookies= balance;

</script>


another page: save.asp

i can't get the value in the cookies ?
<%
dim a

a = response.write("<script>document.cookies</script>")

str_sql ="Insert Into ltrans (staffid, lev_code, frm_date, to_date, frm_time, to_time, no_days, year_ent, balance) Values " _
& "('"&cQuote(request("id"))&"', " _
& "'"&(request("select2"))&"', " _
& "'"&(request("fDate"))&"', " _
& "'"&(request("tDate"))&"', " _
& "'"&cQuote(request("fTime"))&"', " _
& "'"&cQuote(request("tTime"))&"', " _
& "'"&cQuote(request("days"))&"', " _
& "'"&cQuote(request("year_ent"))&"', " _
& "& a &)"
conS.Execute str_sql
%>

buntine
04-01-2005, 05:10 AM
You need to name the cookie when you create it. Do it from the serfer. You don't need JavaScript to work with cookies.

Read this: http://www.w3schools.com/asp/asp_cookies.asp

andrewchai
04-01-2005, 05:26 AM
Thank !