How dim a client value

J

Jack

Hello,
I wrote this code:
<SCRIPT Language=VBScript RUNAT=Server>
dim ab
ab=40
Response.Write "<INPUT type=""button"" value=""Button1"" id=button1
onclick=""ab=" & ab & "+10"">"
Response.Write "<INPUT type=""button"" value=""Button2"" id=button2
onclick=""text1.value=ab"">"
Response.Write "<INPUT type=""button"" value=""Button3"" id=button2
onclick=""text2.value=" & ab & """>"
Response.Write "<BR>"
Response.Write "<INPUT type=""text"" id=text1 name=text1 >"
Response.Write "<INPUT type=""text"" id=text2 name=text2 >"
Response.Write "<BR>"
</SCRIPT>

After Click button1,when click button2 text1 shows 50,but when click button3
text2 shows 40.
Once again click button1,the result is the same.
I want once click button1,ab be plused 10.
That is to say button1 be clicked n times,I want ab=40+10*n
Can you help me
 
R

Ray at

Jack said:
Hello,
I wrote this code:
<SCRIPT Language=VBScript RUNAT=Server>
dim ab
ab=40

That is server-side code.


Response.Write "<INPUT type=""button"" value=""Button1"" id=button1
onclick=""ab=" & ab & "+10"">"

"onclick" is a client-side event.


You cannot change the value of a server-side variable using client-side
code. You will have to reload the page on each click or something along
those lines. Example:

<%
Dim ab
If Request.Form("cmdSubmit") <> "" Then
ab = CInt(Request.Form("cmdSubmit")) + 10
Else
ab = 40
End If
%>
<form method="post">
<input type="submit" value="<%=ab%>" name="cmdSubmit">
</form>

Ray at home
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top