set a var

Discussion in 'HTML' started by mcnewsxp, Oct 8, 2010.

  1. mcnewsxp

    mcnewsxp Guest

    how can i set a variable to true with a button onclick?
    onclick="<%myvar=true%>" or something?

    wrong group?
     
    mcnewsxp, Oct 8, 2010
    #1
    1. Advertising

  2. mcnewsxp

    Rob W. Guest

    Op 8-10-2010 20:22, mcnewsxp schreef:
    > how can i set a variable to true with a button onclick?
    > onclick="<%myvar=true%>" or something?
    >
    > wrong group?


    alt.comp.lang.javascript, maybe?
     
    Rob W., Oct 8, 2010
    #2
    1. Advertising

  3. "Rob W." <> wrote in message
    news:4caf63f7$0$81542$4all.nl...
    > Op 8-10-2010 20:22, mcnewsxp schreef:
    >> how can i set a variable to true with a button onclick?
    >> onclick="<%myvar=true%>" or something?
    >>
    >> wrong group?

    >
    > alt.comp.lang.javascript, maybe?


    They are not very kind to newbies. It can be done in JavaScript, but this
    works with just HTML:

    <html>
    <head><title>SetTrue</title>
    </head>
    <body>
    <input type="hidden" name="myVar" value=false>
    myVar: <input type=text name=myTextBox
    value="Click for myVar"
    OnClick="myTextBox.value=myVar.value" ></input>
    <input type="button" name="btSetTrue"
    value="Set True" onClick="myVar.value=true;
    myTextBox.value=myVar.value;" </input>
    </body>
    </html>

    Paul
     
    Paul E. Schoen, Oct 9, 2010
    #3
  4. "Sherm Pendley" <> wrote in message
    news:...
    > "Paul E. Schoen" <> writes:
    >
    >> "Rob W." <> wrote in message
    >> news:4caf63f7$0$81542$4all.nl...
    >>> Op 8-10-2010 20:22, mcnewsxp schreef:
    >>>> how can i set a variable to true with a button onclick?
    >>>> onclick="<%myvar=true%>" or something?
    >>>>
    >>>> wrong group?
    >>>
    >>> alt.comp.lang.javascript, maybe?

    >>
    >> They are not very kind to newbies. It can be done in JavaScript, but
    >> this works with just HTML:
    >>
    >> <html>
    >> <head><title>SetTrue</title>
    >> </head>
    >> <body>
    >> <input type="hidden" name="myVar" value=false>
    >> myVar: <input type=text name=myTextBox
    >> value="Click for myVar"
    >> OnClick="myTextBox.value=myVar.value" ></input>
    >> <input type="button" name="btSetTrue"
    >> value="Set True" onClick="myVar.value=true;
    >> myTextBox.value=myVar.value;" </input>
    >> </body>
    >> </html>

    >
    > That's not "just HTML" - the contents of both onClick attributes is
    > JavaScript code.


    Well, I was going to dispute that, since I thought the <script
    type=text/javascript> tags were needed, but I found that the browser warned
    about "scripts or active controls" even with just the simple event handlers
    in the input controls. However the script may not necessarily be JavaScript
    unless the browser automatically chooses a script engine that matches the
    syntax. This example may also be done using vbScript:

    <input type="hidden" name="myVar" value=false>
    myVar: <input type=text name=myTextBox
    value="Click for myVar"
    OnClick="myTextBox.value=myVar.value" />
    <input type="button" name="btSetTrue"
    value="Set True" onClick="btSetTrue.value = setDone() " />
    <script type="text/vbscript">
    Function setDone()
    myVar.value=true
    myTextBox.value=myVar.value
    setDone = "Done"
    End Function
    </script>

    Thanks for the clarification. I learned something.

    Paul
     
    Paul E. Schoen, Oct 9, 2010
    #4
  5. Paul E. Schoen wrote:
    > This example may also be done using vbScript:


    Not in my browser it won't. Do not use vbScript for on the web...we are
    trying to rid the shackles of IE6.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Oct 9, 2010
    #5
    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. Alvin Bruney

    Threads.. Session var lost, App var ok

    Alvin Bruney, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    378
    rooster575
    Dec 2, 2003
  2. thomson
    Replies:
    10
    Views:
    2,521
    Eliyahu Goldin
    Jun 20, 2005
  3. thomson
    Replies:
    0
    Views:
    400
    thomson
    Jun 20, 2005
  4. Fred
    Replies:
    3
    Views:
    336
    Alf P. Steinbach
    Aug 10, 2003
  5. Alex Vinokur
    Replies:
    4
    Views:
    489
    Ron Natalie
    Sep 24, 2003
Loading...

Share This Page