Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Changing the onClick function call dynamically

Changing the onClick function call dynamically

MikoLone
10-13-2005, 10:47 PM
okokokokok,

here is the deal. I have a common button right.

<input type="button" id="myButton" onClick="changeStuff();" value="Change Stuff">

And what the changeStuff function wants to do is change the value and change which function the onClick calls. This is how I think the function would go.


function changeStuff(){
document.getElementById('myButton').value = "Change Back";
document.getElementById('myButton').onClick = changeBack;
}

// and the the changeback function would be like ...

function changeBack(){
document.getElementById('myButton').value = "Change";
document.getElementById('myButton').onClick = changeStuff;
}


So I have tried this and it doesn't work so my question is how do you change the function the button calls onClick dynamically. Can it be done.

Thanks for the responses.

MikoLone
10-13-2005, 11:04 PM
OOOOOOOH CRAP.

Sorry guys.

i got it

it jsut needs to be

[code]document.getElementById('myButton').onclick = changeBack;[\code]

BLAH

Sorry.

Feel free to erase this pfine piece of embarassment from the archives of my history.

Thanks.

Kor
10-14-2005, 08:53 AM
U may use this as well:

object.onclick=function(){
..statements, methods, functions, etc...
}


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

Accessing the CD drive from a disk in...the same drive!
Why doesn't 'total' box work!?
Time Refreshing
Problem with popup window
(please) Help with onmouseover images
need help running two sricpts on one page
Javascript / PHP Date Function
Calculating string width in pixels

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics