1
I have the following jsp below, on it the user chooses the status, by choosing the status my javascript shows in an Alert with the information I want to pass to Action to follow the validations and takes the user to another action "locate-stores-state.do", this is occurring, when threshing I get to fall into the Action I wish, but I can’t in any way carry the value of the sgState to Action "locates-stores-state.do"
<script>
function mantemEstado(){
var sgEstado = document.localizarLojasForm["sgEstado"].value;
alert(sgEstado);
form.action = "<c:url value="/localiza-lojas-estado.do"/>";
form.submit();
}
</script>
<div class="fr">
<div class="caminho-link">
<a href="#" class="caminho-link-1" target="_blank">Home </a> <font
face="Arial, Helvetica, sans-serif" color="#007088"
style="font-weight: bold; font-size: 12px;"> >> </font> <a href="#"
class="caminho-link-2" target="_blank">Localizar Lojas</a>
</div>
<div class="slocator-box">
<html:form action="/localiza-lojas.do" method="post" styleId="cadastroCliente2">
<html:hidden property="sgEstado"/>
<div class="slocator-estado">
<html:select tabindex="2" onkeypress="Enter(this.tabIndex, event)" property="sgEstado" styleClass="w80" value="Digite seu E-mail" onchange="javascript:mantemEstado();" >
<html:options collection="listaEstados" property="sgEstado" labelProperty="sgEstado" />
</html:select>
</div>
<div class="slocator-cidade">
<html:select tabindex="2" onkeypress="Enter(this.tabIndex, event)" property="dsCidade" styleClass="w80">
<html:options collection="listaCidades" property="dsCidade" labelProperty="dsCidade" />
</html:select>
</div>
<html:hidden property="sgEstado"/>
<div class="slocator-bairro">
<html:select tabindex="2" onkeypress="Enter(this.tabIndex, event)" property="dsBairro" styleClass="w80">
<html:options collection="listaBairros" property="dsBairro" labelProperty="dsBairro" />
</html:select>
</div>
Create an Hidden field in the form, in the function
mantemEstado()
you assign the value ofsgEstado
in Hidden.– rray
created <html:Hidden Property="sgEstad"/> inside <html:form>, as the value attribute?
– CRAJ
document.getElementById('sgEstado').value = sgEstado;
&#This code goes inside the function, check Hidden id, use the browser’s source code display option. The html is generated by Struts 1.x ?– rray
but I didn’t understand how I pass the value to the action, how do I get a print on my value action that I want for example? Thanks for the attention
– CRAJ
yes, it is generated by the!
– CRAJ