Get checked data from dynamic listview and uplaod to server

风流意气都作罢 提交于 2019-12-24 06:04:05

问题


In image there 4 list as of now sometimes it will be more and below of 4

//I am just uploading data from listview to server. //After selection of first page listview its going to another page (List view with checkbox), Now there are many lists with check box ,so I just want to select few of them and upload that selected list to server using rest api.

//below code for first page

<div class="example-wrapper" data-iscroll>

            <ul data-role="listview" data-insert="true" data-filter="true"  data-filtertext="true" data-role="controlgroup" data-enhanced="true" data- data-input="#search-mini" id="movie-list" data-theme="a"  >


            </ul>
        </div>

// js code for disply data on first page and direct to second listview with chekbox.

$(document).on('pageinit', '#home', function(){      
//    var url = 'http://api.themoviedb.org/3/',
//        mode = 'search/movie?query=',
//        movieName = '&query='+encodeURI('Batman'),        
//        key = '&api_key=5fbddf6b517048e25bc3ac1bbeafb919';    
    var url = 'https://usv.mybluemix.net/USV/Event_creation.jsp';

    $.ajax({
//        url: url + mode + key + movieName ,
        url: url,
        dataType: "json",
        async: true,
        success: function (result) {
             $('#work-in-progress').fadeOut(0);
            ajax.parseJSON(result);


        },
        error: function (request,error) {
            alert('Network error has occurred please try again!');

            document.getElementById("internet_access").innerHTML="No internet access";
        }
    });         
});

$(document).on('pagebeforeshow', '#headline', function(){      
    $('#movie-data').empty();
    $.each(movieInfo.result, function(i, row) {
        if(row.Event_Id == movieInfo.id) {
      var i =1;
            for (var i = 0; i < 4; i++) {

            $('#movie-data').append('<li><input type="checkbox"/>'+row.Speciality+'</li>');


            }
            $('#movie-data').listview('refresh');            
        }
    });    
});

$(document).on('vclick', '#movie-list li a', function(){  
    movieInfo.id = $(this).attr('data-id');
    $.mobile.changePage( "#headline", { transition: "slide", changeHash: false });
});

var movieInfo = {
    id : null,
    result : null
}

var ajax = {  
    parseJSON:function(result){  
        movieInfo.result = result.entries;
        $.each(result.entries, function(i, row) {
            //console.log(JSON.stringify(row));
            $('#movie-list').append('<li><a href="" data-id="'  + row.Event_Id + '">' +'<h3>' + row.Event_Name + '</h3><p2>' + row.Start_Date_Time + '</p2><p>'+row.Event_Id + '</p></a></li>');
        });
        $('#movie-list').listview('refresh').trigger("create");;
    }
}

// below is listview where am creating chekbox

<div data-role="content">
        <ul data-role="listview"  id="movie-data" data-theme="a" data-identifier="1">
              </ul>
    </div>


    <input type="button" id="uploadbutton" onclick="getChecked()" value ="Update"  data-theme="b"/>
</div>

Please help me ,how to upload selected checked list to server using rest api. Please help to learn this. Thanks

来源:https://stackoverflow.com/questions/45768269/get-checked-data-from-dynamic-listview-and-uplaod-to-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!