...

View Full Version : 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...
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum