Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Button Onclick Event Passing Value to Variable

    Reference: IE 6 & JavaScript

    I wish to use a button's onclick event to pass the button's value to a variable.

    How do I code for this?

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    Code:
    <script type="text/javascript">
    var buttonValue;
    </script>
    </head>
    
    <body>
    <form>
    <input type="button" value="myButton" onclick="buttonValue=this.value"
    onmouseover="window.status=buttonValue;return true"
    onmouseout="window.status=buttonValue;return true">
    </form>
    .....Willy

  • #3
    New Coder
    Join Date
    Oct 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you - I see how that works. But I'm still at a loss. The variable I need to access is switch statement variable "var Article" and the switch statement is inside of a function "change()". If you can follow the link below, you can see the code. How do I code to put the button's value into the variable "Article" using the button's onclick event?

    http://www.codingforums.com/showthread.php?t=47127


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •