You need to use the value attribute to whatever value you wish to match to tick the box.

String foo = "bar";

theForm.setFoo(foo);

<html:checkbox property="foo" value="bar" />

Also you use the eval method in javascript, which I don't believe anyone ever needs. It was in vogue a few years back when people with a lot of perl experience turned there hand to javascript. But IMO and the opinion you never need to use it. Certainly you shouldn't need the javascript to tick the boxes the referring action will do that for you.

Cheers Mark

On 8 Jan 2004, at 07:03, Hari_s wrote:

hi all
how can i make checkbox or multibox checked by default when page is loaded...
this is my jsp code but this is not work....(I use java script )


<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page contentType="text/html;charset=windows-1252"%>

<jsp:include page="Header.jsp" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>


<script language = "JavaScript" >
function checkAll() {
for (var j = 1; j <= 10; j++) {
box = eval("document.halForm.seleksi[j]");
if (box.checked == false) box.checked = true;
   }
}

</script>
<body >
<h2>
tes Multi Box
</h2>
<p>
</p>
<html:form action="halAction">
<table border="1" class="table" >
<logic:iterate id="ide" name="halForm" property="data" indexId="ids">
<tr class="tdcontent2" ><td class="tdcontent2" ><html-el:multibox property="seleksi[${ids}]" >true</html-el:multibox><html-el:hidden property="simpan[${ids}]" value="${ide}" />


<bean:write name="ide" /></td></tr>
</logic:iterate>


</table> <html-el:checkbox property="seleksi2" name="halForm" /> <html:button property="tes" onclick="checkAll()" />


<p></p>
<html:submit value="submit" property="tombol" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<html:submit value="cancel" property="tombol"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<html:reset value="reset" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<html:submit value="lagi" property="tombol" />
</html:form>


</body>

can somebody tell me whats wrong with my code......


thank you for your opinion.....


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to