When creating a form, using checkbox to capture user's input is common. So how do we check whether the checkbox is checked when the user submit the form?
Javascript:
// Flag to check whether any checkbox is checked.
var checkB = false;
// Get the form object in the page.
var checkboxLength = document.forms[0];
//Loop through the form elements.
for (var i=0; i<checkboxLength.length; i++)
{
if(checkboxLength.elements[i].checked == true){
checkB = true;
}
}
menu navigation
Showing posts with label Struts. Show all posts
Showing posts with label Struts. Show all posts
Tuesday, March 4, 2014
Tuesday, February 11, 2014
Struts: Nested
Include in JSP:
<%@ taglib prefix="nested" uri="http://struts.apache.org/tags-nested" %>
Define bean:
request.setAttribute("schoolList", schoolList);
Iterate over arraylist:
<nested:select property="school">
<html:options collection="schoolList" property="id" labelProperty="name" />
</nested:select>
</nested:nest>
Tuesday, January 10, 2012
Struts html select tag
To default a selection:
<html:select name="defaultValue" property="value">
<html:optionsCollection name="myKey" value="value" label="label"/>
</html:select>"
Replace select "name" and "value" with the names and values of the HTML struts. You have now selected default HTML struts.
<html:optionsCollection name="myKey" value="value" label="label"/>
</html:select>"
Replace select "name" and "value" with the names and values of the HTML struts. You have now selected default HTML struts.
Subscribe to:
Posts (Atom)