Hi, Thanks for the response. I was calling the function wrong, but
this
did not solve my problem. When I click a row z = always 1. I want to
be able select the appropriate radio button based on the row number it
is in. Is there another way I can do this?
<script type="text/javascript">
var table = document.getElementById("marketingLocations");
var rows = table.getElementsByTagName("tr");
z = rows.length-1;
while(z >= 2){ //The first two rows do not apply
rows[z].onmouseover = function() { this.style.cursor='hand'};
rows[z].onclick = function() {
alert(z);
//eval("document.forms[0].selectedMarketingLocationId["
+(z-2) + "].checked='true'");
//The above is what I want to do.. set the particular
radio button.
}
alert(z);
z--;
}
</script>
> -------- Original Message --------
> Subject: Re: [displaytag-user] Help with adding onclick event
> From: Matt Hughes <[EMAIL PROTECTED]>
> Date: Thu, March 10, 2005 10:23 am
> To: [email protected]
>
> Your problem is in your javascript:
>
> <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>
>
> You are assigning the functon wrong. It should just be:
>
> rows[i].onclick = clickRadio(i)
>
> In your code, the i couldn't be read inside the function like that.
>
>
> On Thu, 10 Mar 2005 08:35:37 -0700, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
> > 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
> >
>
>
> -------------------------------------------------------
> 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
> -------- Original Message --------
> Subject: Re: [displaytag-user] Help with adding onclick event
> From: Matt Hughes <[EMAIL PROTECTED]>
> Date: Thu, March 10, 2005 10:23 am
> To: [email protected]
>
> Your problem is in your javascript:
>
> <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>
>
> You are assigning the functon wrong. It should just be:
>
> rows[i].onclick = clickRadio(i)
>
> In your code, the i couldn't be read inside the function like that.
>
>
> On Thu, 10 Mar 2005 08:35:37 -0700, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
> > 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
> >
>
>
> -------------------------------------------------------
> 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
-------------------------------------------------------
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