I can't seem to change the text of the first option element of a drop down list. I've tried:
var e_option = document.getElementsByTagName("option");
e_option[0].text = "Selectionnaire";
and
var e_option = document.getElementsByTagName("option");
e_option[0].innerHTML = "Selectionnaire";
and
var e_option = document.getElementsByTagName("option");
e_option[0].innerText = "Selectionnaire";
However, nothing seems to change the option's text.
The strangest thing is that:
var e_option = document.getElementsByTagName("option");
e_option[0].style.color = "red";
does change the option to have red coloured font, and
var e_option = document.getElementsByTagName("option");
alert(e_option[0].text);
does alert/popup the current text of the option.
This is the HTML:
...
<td id="control">
<SPAN CLASS="rsfieldcontrol"><INPUT TYPE=TEXT CLASS="rsfieldcontrol" MAXLENGTH=20 SIZE=38 TABINDEX="70" NAME="CONTACTVERIFY1businessPostalCode" VALUE=""></SPAN>
</td>
<td>
</td>
<td>
<SPAN CLASS="rsfieldlabel">Pays :</SPAN>
</td>
<td id="control">
<SPAN CLASS="rsfieldcontrol">
<SELECT CLASS="rsfieldcontrol" TABINDEX="110" NAME="CONTACTVERIFY1businessCountry">
<OPTION LABEL=" - Select an option - " VALUE=" - Select an option - "> - Select an option - </OPTION>
<OPTION LABEL="Afghanistan" VALUE="Afghanistan">Afghanistan</OPTION><OPTION LABEL="Albania" VALUE="Albania">Albania</OPTION>
//I cut out the other 200 odd countries here
<OPTION LABEL="Zimbabwe" VALUE="Zimbabwe">Zimbabwe</OPTION></SELECT></SPAN>
</td>
</tr>
<tr>
<td width="30px">
</td>
<td style="font-weight:bold;">
<SPAN CLASS="rsfieldlabelrequired">* Courriel :</SPAN>
</td>
...
Please note that all select, option and span tags are generated by LexisNexis InterAction, and I cannot change the code. This is why I'm using javascript to change the first option from English to French.
Any help would be appreciated!!