|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Switching image using dwr Hi All,
I had been using DWR since 2 years. I am using DWR with Spring, Hibernate and JSTL tags. when I change the worker to inactive/active i want to change the image as inactive/active. I am unable to change the image as a result of dwr output. I tried setValues, but it can set values with ids, but not for img src. below is the code snippet. can someone help. <c:choose> <c:when est="${cWorkers.active eq 'Y'}"> <!-- active image -->
</c:when> <c:when test="${cWorkers.active eq 'N'}"> <!-- inactive image -->
</c:when> <c:otherwise> </c:otherwise> </c:choose> <script type="text/javascript"> function activateWorkerCallback(data) { DWRUtil.setValue("activeWorkerDiv" , data); } function inActivateWorker(param) { gomsAjax.inActivateWorker(param, inActivateWorkerCallback); return false; } function inActivateWorkerCallback(data) { DWRUtil.setValue("inActiveWorkerDiv" , data); } </script> ![]() ![]() |
|
|
Re: Switching image using dwryou can
use div tags and populate the divs with conditional html (based on if else in a variable) andf then fill the div with the required image wen u activate or deactivate a user
On Thu, Nov 5, 2009 at 2:49 AM, santoshmanya <santoshmanya@...> wrote:
|
|
|
Re: Switching image using dwrHi Guys,
I just fixed the issue, instead of using img src tag, I used input type=image. an it worked. <c:choose> <c:when test="${cWorkers.active eq true}"> <input type="image" id="user_active_${cWorkers.id}" src="active.gif" alt="Active" onclick="return toggleWorkerActive(this,${cWorkers.id});" /> </c:when> <c:when test="${cWorkers.active eq false}"> <input type="image" id="user_active_${cWorkers.id}" src="inactive.gif" alt="Inactive" onclick="return toggleWorkerActive(this,${cWorkers.id});" /> </c:when> <c:otherwise> </c:otherwise> </c:choose> function toggleWorkerActive(element, workerId) { // alert(workerId); gomsAjax.toggleWorkerActive('<%=UserUtils.getUserId(request)%>', workerId, toggleWorkerActiveCB); return false; } function toggleWorkerActiveCB(data) { //alert(data); var element = document.getElementById('user_active_' + data); if(element.alt == "Activate") { element.src = "active.gif"; element.alt = "Inactivate"; } else { element.src = "inactive.gif"; element.alt = "Activate"; } } |
| Free embeddable forum powered by Nabble | Forum Help |