I have an HTML code snippet as shown below:
The value "Test" is just for my reference to ensure that the code is functioning properly :)
<script>
var tfa78 = document.getElementById("tfa_78").selvalue;
if( tfa78 == "karte" )
{
document.getElementById('tfa_2448').innerHTML ='<b>Bei karte anrufen.</b> <br>';
} else {
document.getElementById('tfa_2448').innerHTML ='Test';
}
I'm having trouble getting the desired result from this code. Could it be because I'm using the wrong method to select the dropdown value with the 'selvalue'? Previously, I used a similar code with a textfield and it worked fine, so I suspect there might be an issue with how I'm retrieving the value.
Thank you in advance for any help!
I made some updates to my code based on feedback:
<script>
var tfa78 = document.getElementById("tfa_78").value;
if( tfa78 == 'tfa_2438' ) {
document.getElementById('tfa_2448').innerHTML ='<b> anrufen.</b> <br>';
}else {
document.getElementById('tfa_2448').innerHTML ='Test'+ tfa78;
}
</script>
And here's the dropdown code which cannot be modified:
<select id="tfa_78" name="tfa_78" title="Quelle?" class="required"><option
value="">Bitte auswählen:</option>
<option value="tfa_2438" id="tfa_2438" data-conditionals="#tfa_93"
class="">karte</option>
<option value="tfa_2437" id="tfa_2437" data-conditionals="#tfa_93"
class="">Test</option>
</select>