PDA

View Full Version : Changing the text of a button




newtomacs1234
Jul 29, 2009, 05:38 AM
Hi there,
I am trying to change the text label of a button on a simple iPhone web app I am developing. Using this command I have been able to change the text:

buttonToChange.innerHTML = buttonToChange.innerHTML.replace(buttonToChange.textContent,text);

However after executing this line of code the clickhandler associated with this button will not fire when the button is clicked.

Is there anyway to simply change the text of a button without affecting its internal properties?

Many Thanks



duny
Jul 29, 2009, 07:59 AM
here is a little tid bit of code i use.


if (whatever) {
[button setTitle:@"Hide Navigation Bar" forState:UIControlStateNormal];
[button setTitle:@"Hide Navigation Bar" forState:UIControlStateHighlighted];
} else {
[button setTitle:@"Show Navigation Bar" forState:UIControlStateNormal];
[button setTitle:@"Show Navigation Bar" forState:UIControlStateHighlighted];
}

dejo
Jul 29, 2009, 09:12 AM
here is a little tid bit of code i use.
That's for changing a UIButton's title. I believe the OP has an issue when changing the title of an HTML button, since they are developing a web app. As for why the click no longer works, sorry; I have no idea.