This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes combobox/onLoad Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "combobox/onLoad" Watch "combobox/onLoad" New topic
Author

combobox/onLoad

Claudia Vaz
Ranch Hand

Joined: Nov 13, 2001
Posts: 44
Hello
I have a combobox with some values (for example, Casado and Solteiro).
when i load the page the value in the combobox is the one that is in a database (i use a java class to get this information).
When this value is Casado i want to show a line with a input text for a date and when the value is Solteiro i don't want to show this line.
I though using a onLoad event:
"<tr><td><span id="span_estado_civil" style="position:relative">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="txtVERM"><div align="left"> Designa��o </div></td>
<td class="medium_normal">
<div align="right">
<select size="1" name="estadoCivil" class="caixasTexto" onLoad="javascript:VerificaActivacaoEstadoCivil();onChange="javascript:VerificaActivacaoEstadoCivil();">
<div class="medium_normal"><option value="Solteiro" <%=dadosBD.getEstadoCivil("Solteiro")%>>Solteiro</option></div>
<div class="medium_normal"><option value="Casado" <%=dadosBD.getEstadoCivil("Casado")%>>Casado</option></div>
</select>
</div>
<input type="hidden" name="escondida" onLoad="javascript:VerificaActivacaoEstadoCivil();>
</td>
</tr>
<tr>
<td colspan="99" bgcolor="#ffffff" height="1"><img src="images/transpar.gif"></td>
</tr>
</table>
</span></td></tr>
<tr><td><span id="span_data_estado_civil" style="position:relative">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="txtVERM"><div align="left"> Data do Estado Civil (DD-MM-AAAA) </div></td>
<td><img src="images/transpar.gif" height="20"></td>
<td class="txtVERM">
<div align="right" class="txt">
<input type="text" name="dataCasamento" size="11" maxlength="10" value="<%=dadosBD.getDataCasamento()%>" class="caixasTexto">
</div>
</td>
</tr>
<tr>
<td colspan="99" bgcolor="#ffffff" height="1"><img src="images/transpar.gif"></td>
</tr>
</table>
</span></td></tr>"
with the followinh function
function VerificaActivacaoEstadoCivil()
{
if (document.dadosPessoais.estadoCivil.value!="Solteiro")
{
span_data_estado_civil.style.display = "";
}
else
{
span_data_estado_civil.style.display = "none";
}
}

I hope you can help me!!!
Thanks
Claudia Vaz
Claudia Vaz
Ranch Hand

Joined: Nov 13, 2001
Posts: 44
Hello
I found what i was doing wrong.
the onLoad code shoul be on the body tag.
Claudia Vaz
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: combobox/onLoad
 
Similar Threads
Getting search results on same search page
Struts IE render problem
required fields not populating
Rounding off $$ amounts
Error comes whilke compiling the jsp page