Accessing Radio Buttons in Struts
If you are trying to access radio button that has a compound name, you might have trouble accessing it using document.frmName.elementName. For example:
List<Item> estimateModels = ((UserContainer)container).getEstimationModels();
for(Item item:estimateModels)
{
%>
<html:radio name="estimatorStart" property="componentView.estimateMethod" styleId="componentView.estimateMethod" value="<%=item.getName()%>" /> <a href="#" onclick="window.open('<%=DiamondApplicationProps.getProperty("SERVERPATH").trim()%>/Diamond/BrowseKnowledge.do?action=viewLibraryItemDetails&liId=<%=item.getId()%>');" STYLE="text-decoration:none;color:blue"><%=item.getName()%></a>
<br>
<%}
%>
<html:radio name="estimatorStart" property="componentView.estimateMethod" styleId="componentView.estimateMethod" value="Other" /> <a href="#" STYLE="text-decoration:none;color:blue" onmouseover="this.style.cursor='none'">Other</a>
Having a list like this will give your radio buttons a name called: componentView.estimateMethod
To access these elements as radio buttons in Javascript, you should do something like this:
var radiobuttonitems=document.estimatorStart.elements['componentView.estimateMethod']
for (x=0;x<radiobuttonitems.length;x++ )
{
//alert(radiobuttonitems[x].checked)
if(radiobuttonitems[x].checked)
{
code here
}

0 comments:
Post a Comment