javascript - how to get value from selected (checkbox) listview and uplaod to server jquery mobile -


enter image description here

i want upload particular selected value (checked) in listview on server. there values in list checkbox want select few of them , wants upload server. //below code using set chekcbox on listview

var ajax = {           parsejson:function(result){               movieinfo.result = result.entries;             $.each(result.entries, function(i, row) {                 //console.log(json.stringify(row));                  $('#movie-list').append('<li>'+'<h3>' +'store name  : '+ row.store_name + '</h3><p9>' +'store id : '+ row.store_id + '</p9> <p2><br>store visit date : '+ row.store_visit_date + '</p2><p2><br>comment: '+ row.comments + '</p2><p>' +'store issue : '+ row.issue + '</p><p>'+'user : '+ row.user_name + '</li>');             });              $('#movie-list').listview('refresh');         }     } 

/// below script use upload data server // want selected valu ui , uplaod

$(document).ready(function () {     $("#uploadbutton").click(function () {         var s_no = $("#crm_serialnumber").val();          var user_name = localstorage.getitem("pmusername");          $.ajax({             type: "post",              url: "https://c.jsp",             /* url: "https://d="+filename + "&store_name=" + filename2+ "&ph_no="+filename3,*/             data: {                  "s_no" : s_no,                  "user_name" : user_name             },             /*             data: "store_id ="+ filename + "&store_name =" +filename2 + "&ph_no =" + filename3 ,             */             success: function (msg,string,jqxhr) {                 window.location='home.html';                  $("#result").html(msg,string,jqxhr)                alert("data uploaded: ");             }         });     }); }); 

//please me solve problem learning . thanks

first of all, when populate list, believe should assign identifier list items, can later, when need post selection back.

to that, can set own custom data-attribute each list item, same way assigning text , captions paragraphs , headings.

after that, can filter checked checkboxes , retrieve list item belonging to:

function getchecked() {    $("#movie-list :checkbox:checked").each(function(index) {      // retrieve list item      var listitem = $(this).closest("li");      // data associated      var identifier = listitem.data("identifier");      var storename = listitem.data("store-name");      console.log(index, identifier, storename);    });  }
#movie-list > li{    padding: 0 !important;  }    #movie-list .ui-checkbox {    margin: 0 !important;  }    #movie-list .ui-checkbox .ui-btn {    border-width: 0 !important;    border-radius: inherit !important;  }
<!doctype html>  <html>  <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">    <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css">    <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>    <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>  </head>  <body>    <div id="page-list" data-role="page">      <div role="main" class="ui-content">        <button class="ui-btn ui-mini" onclick="getchecked()">get checked items</button>        <br>        <ul id="movie-list" data-role="listview">          <li data-identifier="1" data-store-name="store-1">            <input type="checkbox" name="checkbox-1" id="checkbox-1" />            <label for="checkbox-1">              <h2>stephen weber</h2>              <p><strong>you've been invited meeting @ filament group in boston, ma</strong></p>              <p>hey stephen, if you're available @ 10am tomorrow, we've got meeting jquery team.</p>            </label>          </li>          <li data-identifier="2" data-store-name="store-2">            <input type="checkbox" name="checkbox-2" id="checkbox-2" />            <label for="checkbox-2">              <h2>jquery team</h2>              <p><strong>boston conference planning</strong></p>              <p>in preparation upcoming conference in boston, need start gathering list of sponsors , speakers.</p>            </label>          </li>          <li data-identifier="3" data-store-name="store-3">            <input type="checkbox" name="checkbox-3" id="checkbox-3" />            <label for="checkbox-3">              <h2>avery walker</h2>              <p><strong>re: dinner tonight</strong></p>              <p>sure, let's plan on meeting @ highland kitchen @ 8:00 tonight. can't wait!</p>            </label>          </li>        </ul>        </div>    </div>  </body>  </html>


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -