Entry
Can I send a value for one variable on button click in ASP?
May 13th, 2008 07:51
i can do it, T Bone, Gomathi Karthikeyan,
First of all, your question is not very precise, anyways i will try to
answer it the best i can.
1.>If you want to send the variable's value to the database then you
have to connect to the database. Depending on kind of database you are
using the connection string would be different.
I will explain with an example with ms-access as database and am using
mysql.
<%@Language=VBScript %>
<form name="logchk" action="login.asp" method="get"> 'send variable to
same page but if condition is there
<%if not Request.Querystring("flag")="true" then%>
'get variable here and send another hidden variable flag whose value is
true.
<%else
dim connstr,conn
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\NameofFolder\Database.mdb;Persist Security
Info=False"
set conn = server.createobject("ADODB.connection")'Connection is there
now.
conn.open connstr
strsql="update tablename set... where "
conn.Execute (strsql)
%>
Now what happens in the above code is same page is called after
variables have been taken and then the else part is run as we have sent
value of flag as true and then database is connected to and we update
the database.
2> If you want to send the variable's value to another page this can be
done by either using sessions or cookies or attaching the value in the
url of the next page.
http://www.stupidarticles.com
http://www.halazona.com
http://www.shikapika.com
http://www.stakoza.com
http://www.uploadarticles.com
http://www.ganazat.com
http://www.damima.com
http://www.tarabiza.com
http://www.articlesxarticles.com
http://www.articlesfreedirectory.com