How to put a color on the tr of a dynamically selected Radio
Is it possible to change the color of the line after the user selects a radio from the list taking into account that I am submitting the page ? the problem is that I am not able to do because as you can see below my Table pulls the data from the bank dynamically
Listagenda
That and Table
<table width="199" border="1" class="table table-condensed" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<thead class="style4">
<tr bgcolor="${cortop}" >
<th width="21" align="left" > </th>
<th width="178" align="left" ><strong>EXAMES / PROCEDIMENTOS</strong></th>
</tr>
<c:forEach var="item" items="${listarAgenda}">
<tr bgcolor="#F4F4F4">
<th align="left" nowrap="nowrap"><input type="radio" name="radio4" id="radio4" value="radio4" onclick="JavaScript:selecionarAgenda(${item.idAgenda},'${item.agenda}',${item.idLocalAtend},'${item.local}', 0, '');" /></th>
<th align="left" nowrap="nowrap"><a href="#" onclick="JavaScript:selecionarAgenda(${item.idAgenda},'${item.agenda}',${item.idLocalAtend},'${item.local}', 0, '');">${item.agenda}</a></th>
</tr>
</c:forEach>
</thead>
</table>
JavaScript: selectagenda
function selecionarAgenda(idAgenda, nomeAgenda, idlocal, local, idmedico, medico){
document.forms[0].sc.value=document.getElementById("div1").scrollTop-2;
diaSemana();
if(idAgenda > 0){
document.formConsulta.selectMedico.value=0;
document.formConsulta.medico.value='';
document.formConsulta.idagenda.value=idAgenda;
document.formConsulta.nomeagenda.value=nomeAgenda;
document.formConsulta.selectLocal.value=idlocal;
document.formConsulta.local.value=local;
document.formConsulta.idtipoconsulta.value=4;
document.formConsulta.idmedico.value=0;
document.formConsulta.action='<%=request.getContextPath()%>/controlador?acao=agendaunica';
document.formConsulta.submit();
}else{
document.formConsulta.nomeagenda.value='';
document.formConsulta.idagenda.value=0;
document.formConsulta.idtipoconsulta.value=0;
document.formConsulta.idmedico.value=idmedico;
document.formConsulta.medico.value=medico;
MM_jumpMenu();
}
}
Does my Jsp
communicate with the servlet
controller?acao=scheduleunica doing so submit select radio
. It would be possible to change the color of the selected radio after the submit because the user complains that he does not remember which schedule he is on.
1 answers
Look What you you can do is the following. From what I've seen, you own ${item.idAgenda} , assign the id to your row and write to your selection method.
document.formConsulta.agendaSelecionada.value= idAgenda;
Then in your java, record this parameter, so that on the return you can know the selected schedule and add a CSS class to color the background. You can do something like this:
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("id").className = "corFundo";
});
Another alternative would be to do via GET. In the submit of your form save the calendar parameter selected and retrieve the same from url:
Ex: www.meusite.com.br/agendas?as=12