How to put a color on the tr of a dynamically selected Radio

0

Is it possible for the line color to change 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 it as you can see below my Table pulls the database data dynamically

  

ListingAgenda

this is the 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" >&nbsp;</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();
                }
            }

My Jsp communicates with servlet controller? action = agendaunica thus doing the submit of the page after selecting radio . I would like to change the color of the selected radio after the submit because the user complains that he does not remember which Agenda he is in.

    
asked by anonymous 16.02.2017 / 11:43

1 answer

1

Look what you can do is the following. From what I saw, you have $ {item.idAgenda} , assign the id to your row and write to your selection method.

document.formConsulta.agendaSelecionada.value= idAgenda;

Then in your java, save this parameter, so that in 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 selected calendar parameter and retrieve it from the url:

Ex: www.meusite.com.br/agendas?as=12

    
16.02.2017 / 13:43