I don't know how this meaningless thing is driving my nuts, well, I have as follows:
I'm trying to set a radio button value when a modal form is displayed, this is the code for the radio button:
<h:selectOneRadio layout="lineDirection" class="validate[required]" id="publico-form" value="#{lineasBean.publico}">
<f:selectItem id="y" itemLabel="SI" itemValue="Y"/>
<f:selectItem id="n" itemLabel="NO" itemValue="n"/>
</h:selectOneRadio>
That render as follows:
<table id="form-insertar-linea:publico-form" class="validate[required]">
<tr>
<td>
<input type="radio" name="form-insertar-linea:publico-form" id="form-insertar-linea:publico-form:0" value="Y" /><label for="form-insertar-linea:publico-form:0"> SI</label> </td>
<td>
<input type="radio" name="form-insertar-linea:publico-form" id="form-insertar-linea:publico-form:1" value="n" /><label for="form-insertar-linea:publico-form:1"> NO</label> </td>
</tr>
</table>
Then, with a Javascript function I'm trying to select with the follow code:
$("input:radio[name='form-insertar-linea:publico-form']").attr('checked',true);
That works totally but only for 'NO' value, what I want is select the button value according the value what I want 'Y' or 'N', I'm tried with select by id but jQuery doesn't recognize the pattern ":" when I make the selector:
$("#form-insertar-linea:publico-form:0").attr('checked',true);
Also I tried this one based on nth-child but nothing happens:
$("input:radio[name='form-insertar-linea:publico-form']:nth-child(0)").attr('checked',true);
Any ideas?
Regards!