How can I plus the value

J

Jack

Hello,
I wrote this code:

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
dim ab
ab=0
Response.Write "<INPUT type=""text"" id=customername name=customername
onchange=""ab=ab+1"" value=""abc"">"
Response.Write "<BR>"
Response.Write "<INPUT type=""text"" id=text1 name=text1 value =" & ab &
">"
....
</SCRIPT>

But onchange the customername's text ,ab's value was no plus.Can you help
me.
 
B

Bob Barrows

Jack said:
Hello,
I wrote this code:

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
dim ab
ab=0
Response.Write "<INPUT type=""text"" id=customername
name=customername onchange=""ab=ab+1"" value=""abc"">"
Response.Write "<BR>"
Response.Write "<INPUT type=""text"" id=text1 name=text1 value =" &
ab & ">"
...
</SCRIPT>

But onchange the customername's text ,ab's value was no plus.Can you
help me.

Your problem is lack of understanding where the code is executing.

Everything in the script block runs at the server. That means the variable
you declared in that script block is only visible to the code that is
running on the server.

The onchange event takes place at the client. The code running on the client
machine has no idea about any variables that were declared in the
server-side code.. You will need to write some client-side code to declare a
client-side variable in the window's onload event, along with code in the
INPUT's onchange event to display the new value for ab when it gets changed.

You should follow up on a client-side coding newsgroup (look for one with
"dhtml" in its name, or go to m.p.scripting.vbscript or
m.p.scripting.jscript)

HTH,
Bob Barrows
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top