How text101 can't show 'eee'

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

  1. Jack

    Jack Guest

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

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


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




    "Jack" <> wrote in message
    news:...
    > 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
    >
     
    Aaron Bertrand [MVP], Nov 11, 2003
    #2
    1. Advertising

  3. Jack

    Ray at Guest

    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


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

    Ray at Guest

    This is what you call VJ Script. :p

    Ray at home

    "Aaron Bertrand [MVP]" <> wrote in message
    news:...
    > "eee" must be in quotes as well, so you have to double them up to include
    > them:
    >
    >
    > Response.Write("<input ... onchange='text101.value=""eee"";'>")
    >
    >
    >
    >
    > "Jack" <> wrote in message
    > news:...
    > > 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
    > >

    >
    >
     
    Ray at, Nov 11, 2003
    #4
  5. Jack

    Jack Guest

    Why text100 can't be showed

    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
     
    Jack, Nov 11, 2003
    #5
  6. Jack

    Ray at Guest

    Re: Why text100 can't be showed

    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

    "Jack" <> wrote in message
    news:eIK5w$...
    > 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
    >
     
    Ray at, Nov 11, 2003
    #6
  7. Re: Why text100 can't be showed

    > 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.
     
    Aaron Bertrand [MVP], Nov 11, 2003
    #7
  8. Re: Why text100 can't be showed

    > 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)
     
    Aaron Bertrand [MVP], Nov 11, 2003
    #8
  9. Jack

    Jack Guest

    Re: Why text100 can't be showed

    This problem was solved.
    I don't know jscript at all.I will study more.
    Thank you for your help!
     
    Jack, Nov 11, 2003
    #9
  10. Jack

    Ray at Guest

    Re: Why text100 can't be showed

    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

    "Jack" <> wrote in message
    news:...
    > This problem was solved.
    > I don't know jscript at all.I will study more.
    > Thank you for your help!
    >
     
    Ray at, Nov 11, 2003
    #10
    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. Matt

    TO show or NOT to show

    Matt, May 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    389
  2. Disco Octopus

    to show image or to show flash

    Disco Octopus, May 13, 2004, in forum: HTML
    Replies:
    7
    Views:
    2,432
    Toby A Inkster
    May 14, 2004
  3. Replies:
    1
    Views:
    584
    Evertjan.
    Sep 30, 2005
  4. Alex van der Spek

    IDLE/Python on Asus EEE PC

    Alex van der Spek, Jan 25, 2009, in forum: Python
    Replies:
    1
    Views:
    402
  5. Replies:
    1
    Views:
    178
    Evertjan.
    Sep 30, 2005
Loading...

Share This Page