Hi, I am an inexperienced wed developer so bear with me. I like the
display tag library a lot but I have a problem that will be a show
stopper for me if I can't work it out.
I have a table that when any cell in a row is clicked it must select the
radio button associated with that row (there is one radio button per
row).
The code I currently have is below:
<display:table name="sessionScope.marketingLocations"
id="marketingLocations" cellpadding="2" cellspacing="0"
width="100%">
<% if(count!=0){%>
<logic:equal property="uniqueIdentifier"
name="marketingLocations"
value="<%=selectedMarketingLocationId%>" >
<%foundSelected=true;
temp=true;
selectedRowIndex=count+1;
%>
</logic:equal>
<display:column headerClass="columnhead" class="listrow"
title=""
width="3%"><input type="radio" <%if(temp){%>checked="checked"<%}%>
name="selectedMarketingLocationId" value="<bean:write
name="marketingLocations" property="uniqueIdentifier"
/>"/></display:column>
<%}else{%>
<display:column headerClass="columnhead" class="listrow"
title=""
width="3%"> </display:column>
<%}%>
<display:column headerClass="columnhead" class="listrow"
property="name" style="width:24%" title="Name" />
<display:column headerClass="columnhead" class="listrow"
property="address.street1" style="width:30%" title="Street" />
<display:column headerClass="columnhead" class="listrow"
property="address.city" style="width:10%" title="City" />
<display:column headerClass="columnhead" class="listrow"
property="address.state.value" style="width:10%" title="State" />
<display:column headerClass="columnhead" class="listrow"
property="address.zipCode" style="width:10%" title="ZIP Code" />
<logic:equal name="marketingLocations" property="marketingAllowed"
value="true">
<display:column headerClass="columnhead" class="listrow"
style="width:10%" title="Marketing Allowed">Yes</display:column>
</logic:equal>
<logic:equal name="marketingLocations" property="marketingAllowed"
value="false">
<display:column headerClass="columnhead" class="listrow"
style="width:10%" title="Marketing Allowed">No</display:column>
</logic:equal>
<%count++;
temp=false;%>
</display:table>
<script type="text/javascript">
var table = document.getElementById("marketingLocations");
var rows = table.getElementsByTagName("tr");
for (i=2; i < rows.length; i++) {
rows[i].onmouseover = function() { this.style.cursor='hand'};
rows[i].onclick = function(){ clickRadio(i) };
}
</script>
The problem is the script doesn't work as desired. When I call the
clickRadio(i) function, the value passed is always rows.length, no
matter which row is clicked. Thus, the i must not be assigned
dynamically, rather it is assigned when the row is clicked (at which
time the loop has completed).
Does anyone have a solution to the problem?
The mouseover event works perfect
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user