I need to change on the fly the class of an HTML element depending on the choice made by an user with a radio button but the problem is that I get the message
“Erreur : missing ) after argument list
Fichier Source : website
Ligne : 1, Colonne : 71
Code Source :
document.getElementById(‘jj_conjoint’).setAttribute(‘class’,’validate[‘required’]’);”.
my code :
<label>Husband/Wife :</label>
<input type="radio" name="not_single" value="yes" onclick="document.getElementById('birthdate_partner').setAttribute('class','validate['required']');">yes
<input type="radio" name="not_single" value="no" checked="checked">no
<select name="birthdate_partner" id="birthdate_partner">
<option value="" selected="selected">-</option>
<option value="1987" >1987</option>
<option value="1986" >1986</option>
<option value="1985" >1985</option>
<option value="1984" >1984</option>
</select>
is referring to a variable called
birthdate_partner. Instead, you should pass the ID as a string:The variable
birthdate_partneris never assigned to some value, so it isundefined, resulting in this being called:which does not work.