How dim a client value

Discussion in 'ASP General' started by Jack, Nov 11, 2003.

  1. Jack

    Jack Guest

    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
    Jack, Nov 11, 2003
    #1
    1. Advertising

  2. Jack

    Ray at Guest

    "Jack" <> wrote in message
    news:...
    > 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
    Ray at, Nov 11, 2003
    #2
    1. Advertising

  3. Jack

    Jack Guest

    Thank you very much
    Jack, Nov 11, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    3
    Views:
    390
    Chris Mahoney
    Jul 13, 2003
  2. Andreas Klemt
    Replies:
    1
    Views:
    444
    Steve C. Orr, MCSD
    Jul 23, 2003
  3. Denis Palas
    Replies:
    1
    Views:
    491
  4. Florian Kaufmann
    Replies:
    1
    Views:
    367
  5. Andrew Poulos

    Return inex position of value in multi dim array

    Andrew Poulos, Mar 2, 2005, in forum: Javascript
    Replies:
    5
    Views:
    125
Loading...

Share This Page