Hey guys, what's up? First post here (although i've been visiting MacRumors for the past years).
I've recently downloaded XCode and begun messing around with it a couple of days ago, but I'm afraid I've been having some problems with even a simple "change the text label" funcionality (if we could call it that lol).
More specifically, I want to try out a very basic operation of "Click this button to change that label's text to XYZ". Now, the tutorials at developer.apple.com haven't been particularly helpful. In fact, I am quite surprised to see that such a trivial thing does not have a tutorial for it or something like it.
Most documentation I've seen are usually either too simplified (e.g.: no code required) or not intuitive at all (damn, I miss PHP already lol), so I'd like to hear what you have to say.
Anyway, to the code - this is in the main js file, called iTSLS.js in this case.
I have a button (id: button) - which has an event handler which trigger the "mudar_texto" (translating: change text) function.
The code is:
Now, the text label which I want to change has the correct ID ("showStats") and, as you can see, the code was even copied and pasted directly from the code snippet library. I'm just wondering why on earth won't this work.
Thanks in advance guys,
Hal
I've recently downloaded XCode and begun messing around with it a couple of days ago, but I'm afraid I've been having some problems with even a simple "change the text label" funcionality (if we could call it that lol).
More specifically, I want to try out a very basic operation of "Click this button to change that label's text to XYZ". Now, the tutorials at developer.apple.com haven't been particularly helpful. In fact, I am quite surprised to see that such a trivial thing does not have a tutorial for it or something like it.
Most documentation I've seen are usually either too simplified (e.g.: no code required) or not intuitive at all (damn, I miss PHP already lol), so I'd like to hear what you have to say.
Anyway, to the code - this is in the main js file, called iTSLS.js in this case.
I have a button (id: button) - which has an event handler which trigger the "mudar_texto" (translating: change text) function.
The code is:
Code:
function mudar_texto(event)
{
if (window.widget)
{
// Values you provide
var textFieldToChange = document.getElementById("showStats"); // replace with ID of text field
var newTextFieldText = "FFS"; // value to change range to
// Text field code
textFieldToChange.value = newTextFieldText;
}
}
Now, the text label which I want to change has the correct ID ("showStats") and, as you can see, the code was even copied and pasted directly from the code snippet library. I'm just wondering why on earth won't this work.
Thanks in advance guys,
Hal