Divyang
Divyang

Reputation: 651

how to get values from display tag to java code?

There is a jsp page where I put my name and this display column shows the occupant details.It shows occid, firstname etc. The prob is that I want to use this occid in toggle1(occid) and toggle2 but cant seem to use it. Is there any wait to access the occid from display column in toggle1 and toggle2? It will be of great help.

 <display:table name="sessionScope.List" pagesize="2"
                               export="true" sort="list">  

                    <display:column  property="occid" title=" Occupant ID" style="text-align:center;" ></display:column>
                    <display:column  property="firstName" title="First Name" style="text-align:center;" ></display:column>
                    <display:column  property="lastName" title="Last Name" style="text-align:center;"  ></display:column>
                    <display:column  property="sonOf" title="Father's Name" style="text-align:center;"  ></display:column>
                    <display:column  property="district" title="District" style="text-align:center;"  ></display:column>
                    <display:column  property="village" title="Village"  style="text-align:center;" ></display:column>

                    <display:column  title="Reservation Form" style="text-align:center;">
                        <a href="javascript:toggle1('${occid}')">
                            Show reservation details
                        </a>
                    </display:column>

                    <display:column  title="Agreement Form" style="text-align:center;">
                        <a href="javascript:toggle2('${occid}')">
                            Show agreement details
                        </a>
                    </display:column>

And this is the toggle javascript code.

function toggle1(occid)
{
alert(1);
$.ajax({
    type: "GET",
    url: "getReservationDetails",
    data: "occid="+occid,              
    success: function(data){
        document.getElementById("resdet").innerHTML = data;   
    }
});
}

Upvotes: 0

Views: 2474

Answers (1)

prakashpoudel
prakashpoudel

Reputation: 577

add id with display:table as this

<display:table name="sessionScope.List" pagesize="2" export="true" sort="list" id="itemName">

and within display:column use varialbe itemName.occid as this

<a href="javascript:toggle1('${itemName.occid}')">

Upvotes: 1

Related Questions