having a problem with my jsp

hi

I am new to this forum. i am using struts in my jsp. the first time the jsp is displayed the checkbox is not checked., which by default is not checked.

The label CRA should only be displayed when the checbox is checked., and when again the checkbox is unchecked it should not be displayed.

I used javascript to do this but when the page is displayed for the first time the label is getting displayed which should not happen since the checkbox is unchecked, but the javascript function works fine when i again check and uncheck the checkbox. so the problem is only when the page gets displayed for the first time.

can anyone help me find a solution for this

code:

<script language="javascript">

function hide (section) {

elem = document.getElementById(section);

if (elem.style.display=="") {

elem.style.display="none";

}

}

function show (section) {

elem = document.getElementById(section);

if (elem.style.display=="none") {

elem.style.display="";

}

}

function toggleCRA(obj) {

if (obj.checked == false) {

hide("cra_Label_0_row");

}

else {

if (obj.checked == true)

{

show("cra_Label_0_row");

}

}

}

</script>

<html:form>

<table>

<tr id="cra_check_0_row">

<td class="Data">Will proceeds go to different address </td>

<td class="Example">

<html:checkbox property="diffAdd" styleId="cra_check_0" onClick="toggleCRA(this)"/>

</td>

</tr>

<tr id="cra_Label_0_row">

<td class="Data">CRA </td>

</tr>

</table>

</html:form>

thank you

makhtar

[1835 byte] By [makthara] at [2007-11-27 6:14:26]
# 1
call this fn. in body tag onLoad.function onLoadEvent() {document.getElementById('diffAdd').checked = false;}
skp71a at 2007-7-12 17:23:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks skp71 but i need to hide the label (CRA) from being displayed. can u plz help me with this problem.thanksmansoor
makthara at 2007-7-12 17:23:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Why don't you put both blocks within DIV tags, that way it is very easy to hide and show.
skp71a at 2007-7-12 17:23:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...