Hi,

I am working on dynamically updating the text of an input box label in the create_account.php file so that when a different country is selected the text in front (i.e. the label) of an input text field is changed. This for a new field I have added but for the sake of illustration I shall use "firstname" here.
I have it working fine so my question is purely academic/curiosity-based

Accessing the text box (not the label) text to put some text inside it is fairly straightforward using the id, which for example is already id="firstname”, so the JavaScript code is
document.create_account.firstname.value = some new text

However the preceeding label for this text box does not have an id to target it. It has instead the for=”firstname” which ties it (as I vaguely understand it) to the id of the following text box.

So the question is, since the label does not have an id, how should I access this label text?

I have solved this by giving the label its own id=”firstname_label” and then using this:
document.getElementById('firstname_label').innerHTML = some new text

but I’m sure there must be a more correct way to do it by using what is already there rather than giving it its own id.

As I say, it works so this “issue” is for nit-pickers only like me!

Regards
Steve