View Full Version : Button Onclick Event Passing Value to Variable

11-09-2004, 02:31 AM
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?

Willy Duitt
11-09-2004, 02:43 AM
Try this:

<script type="text/javascript">
var buttonValue;

<input type="button" value="myButton" onclick="buttonValue=this.value"
onmouseover="window.status=buttonValue;return true"
onmouseout="window.status=buttonValue;return true">


11-09-2004, 11:46 PM
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?