Hi, I'm new to jquery, please bear with me. I created a page from code i found online. I have 2 divs, 1 with data from mysql, the other is empty. I can make a selection by clicking a checkbox, which each line has one, and then click a button and move all checked items to bottom div. I want to check all the items I've moved to the bottom div and post them to a processing page, but this is where it gets weird. let's say I check 3 lines, any 3, and move them down the first 3 in the top div are what's sent to the process page. This is the code I'm using.
Code:
$(document).ready(function () {
// Uncheck each checkbox on body load
$('#batch_content .selectit').each(function() {this.checked = false;});
$('#lower_batchwin .selectit').each(function() {this.checked = false;});
$('#batch_content .selectit').click(function() {
var userid = $(this).val();
$('#user' + userid).toggleClass('innertxt_bg');
});
$('#lower_batchwin .selectit').click(function() {
var userid = $(this).val();
$('#user' + userid).toggleClass('innertxt_bg');
});
$("#move_down").click(function() {
var users = $('#lower_batchwin .innertxt2').size();
var lower_batchwin = $('#batch_content .innertxt_bg').size();
// if (users + lower_batchwin > 5) {
// alert('You can only chose maximum 5 users.');
// return;
// }
$('#batch_content .innertxt_bg').each(function() {
var user_id = $(this).attr('userid');
$('#select' + user_id).each(function() {this.checked = false;});
var user_clone = $(this).clone(true);
$(user_clone).removeClass('innertxt');
$(user_clone).removeClass('innertxt_bg');
$(user_clone).addClass('innertxt2');
$('#lower_batchwin').prepend(user_clone);
$(this).remove();
});
});
$("#move_up").click(function() {
$('#lower_batchwin .innertxt_bg').each(function() {
var user_id = $(this).attr('userid');
$('#select' + user_id).each(function() {this.checked = false;});
var user_clone = $(this).clone(true);
$(user_clone).removeClass('innertxt2');
$(user_clone).removeClass('innertxt_bg');
$(user_clone).addClass('innertxt');
$('#batch_content').append(user_clone);
$(this).remove();
});
});
$('#view').click(function() {
var users = '';
$('#lower_batchwin .innertxt2').each(function() {
var user_id = $(this).attr('userid');
if (users == '')
users += user_id;
else
users += ',' + user_id;
});
alert(users);
});
});