How text101 can't show 'eee'

J

Jack

I wrote this code:
<SCRIPT LANGUAGE=JScript RUNAT=Server>
....
Response.Write("<INPUT type=text id=text100 name=text100
onchange='text101.value=eee'>");
Response.Write("<BR>");
Response.Write("<INPUT type=text id=text101 name=text101 >");
Response.Write("<BR>");
....
</SCRIPT>
But,when text100's onchange,text101 not show 'eee'.
Can you help me
 
A

Aaron Bertrand [MVP]

"eee" must be in quotes as well, so you have to double them up to include
them:


Response.Write("<input ... onchange='text101.value=""eee"";'>")
 
R

Ray at

Because in that context, eee is an undefined variable, not a string. Look
at a view source, It'll say:

<INPUT type=text id=text100 name=text100 onchange='text101.value=eee'>

You want it to say:

<INPUT type=text id=text100 name=text100 onchange="text101.value='eee';">

To get that, you'd either just stick it in html out of your script block, or
response.write it like:

Response.Write("<INPUT type=text id=text100 name=text100
onchange=\"text101.value='eee';\">");

Ray at home
 
J

Jack

Thank you very much.
I wrote this code:
<SCRIPT LANGUAGE=JScript RUNAT=Server>
....
var abc;
abc=100;
Response.Write("text100:")
Response.Write("<INPUT type=text id=text100 name=text100
onchange=\"text101.value=" & abc & "\">");
Response.Write("<BR>");
Response.Write("<INPUT type=text id=text101 name=text101 >");
Response.Write("<BR>");
....
</SCRIPT>

But text100 can't be showed.
I want when text100 onchange,text101 show abc's value.
Can you help me
 
R

Ray at

Please don't take these questions the wrong way.

Do you know jscript at all?
Do you understand the difference between server-side scripting and
client-side?

The concatenator operator in jscript is + not &.

Ray at home
 
A

Aaron Bertrand [MVP]

Response.Write("<INPUT type=text id=text100 name=text100
onchange=\"text101.value=" & abc & "\">");

You still need to put quotes around abc! Let's start with the basics:

Let's compare this:

Response.Write("<Input type=Text>");

With this:

Response.Write("<Input type=\"Text\">");

(View source to see the difference in the browser.)

Now, compare what you have posted, to this:

Response.Write("<input type=text name=text100 onchange=\"text101.value='" +
abc + "';\">");

Notice my extra quotes??? This is because abc is a variable in
*SERVER-SIDE* code, but it is just a string in *CLIENT-SIDE* code.

If you can't follow this, then I'll echo Ray and prefix this with no
offense, don't take this the wrong way, etc., but you need to go over some
basic ASP tutorials to grasp the difference between client-side and
server-side code. Also, if you're not that comfortable with JScript syntax,
I suggest sticking to VBScript on the server side. Far more examples out
there in VBScript, and far more people capable of helping you quickly...

Also, could you consider encoding your messages in a standard format?
iso-2022-jp does really weird things to my newsreader.
 
A

Aaron Bertrand [MVP]

Response.Write("<input type=text name=text100 onchange=\"text101.value='"
+
abc + "';\">");

(And also, you should fully reference the input field, for greatest browser
compatibility; e.g., document.formname.text101.value)
 
J

Jack

This problem was solved.
I don't know jscript at all.I will study more.
Thank you for your help!
 
R

Ray at

I suggest you skip asp and go to asp.net if you don't know anything yet. If
you don't want to do that, I second the suggestion to use vbscript for ASP.

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top