Json return anther window.

|


     //children window



<c:forEach var="obj" items="list" varStatus="status">

           <input type="check" name="chkRow" value="${status.count}"/>

           <input type="hidden" id="num${status.count}"  value="${obj.num}"/>

           <input type="hidden" id="qty${status.count}"  value="${obj.qty}"/>

</c:forEach>

        



$('#btnSel').click(function() {

var jsonArray  = new Array();

var rtnObj = new Object();

$("input[name='chkRow']").each(function(index) {

if(this.checked){

var id = this.value;

var num =  $("#num"+id).val();

var qty =  $("#qty"+id).val();

  var jsonObj = new Object();

jsonObj.num = num;

jsonObj.qty = qty;

jsonArray.push(jsonObj);

}

});

rtnObj.list = jsonArray;

var obj =  JSON.stringify(rtnObj);

alert("return object"+obj);

$('#jsonArray',opener.document).val(obj); 

//close

window.close();

});



         //parent window


        <tbody id="tbody" >

        </tbody>

        <input type="hiden" id="jsonArray"/>



$("#jsonArray").bind('input propertychange', function() {

var jsonArr = $(this).val(); 

var json = JSON.parse(jsonArr);

        var arr = new Array();

        var listHtml ='';

  $.each(json.list, function(index, object) {


listHtml += '<tr class="al" onMouseOver="this.style.backgroundColor=\'#f1f6fd\';" onMouseOut="this.style.backgroundColor=\'\'" >';

listHtml += '<td align="center">'+object.num+'</td>';

listHtml += '<td align="center">'+object.qty+'</td>';

listHtml += '<td align="center"></td>';

listHtml += '</tr>';

}); 

     

$('#tbody').html(listHtml);  

   

}); 


'Java script' 카테고리의 다른 글

Json return anther window.  (0) 2014.03.16
Java Script Null Check.  (0) 2013.10.14
Trackback 0 And Comment 0
prev | 1 | 2 | 3 | 4 | 5 | next