Comments (2)
Hi,
I experienced some problems with the plugin myself: when you submit the form, all the items in the list were posted, whether or not you selected some.
For those who want this to work, I created a little workaround: when the button in the form is clicked, all hidden input fields of the items that are not selected are removed. As a result, only the items you select will be posted.
HTH!
Best regards,
Michael
(warning, there is PHP code in here, you probably want to remove this ;))
<script type="text/javascript">
$(document).ready(function() {
$(".fbfriendids").hide();
//id(ul id),width,height(element height),row(elements in row)
$.fcbkListSelection("#fcbklist","400","50","2");
$("#next").click(function() {
$('#fcbklist').children().each(function(i,listEl){
if(!$(listEl).hasClass("liselected")) {
// item is not selected, so uncheck the checkbox
$(listEl).find("input").attr('checked', false);
} else {
$(listEl).find("input").attr('checked', true);
}
});
$("#fbform").submit();
});
// setup form validation so that at least 1 friend needs to be selected
jQuery.validator.addMethod("facebookfriendsrequired", function(value, element) {
var fbFriendsValid=false;
$('#fcbklist').children().each(function(i,listEl){
if($(listEl).hasClass("liselected")) {
fbFriendsValid = true;
}
});
return fbFriendsValid;
}, "Please select at least 1 friend.");
$("#invitefacebookfriends").validate({
invalidHandler: function(form,validator) {
var errors = validator.numberOfInvalids();
if (errors) {
$(".errorSpan").show().html("Please select at least 1 friend.");
} else {
$(".errorSpan").hide();
}
}
});
});
</script>
<span id="errorSpan" class="errorSpan"></span>
<form action="test.php" method="post" id="fbform">
<ul id="fcbklist">
<?php foreach($friends as $friend) { ?>
<li>
<img src="https://graph.facebook.com/<?php echo $friend['id']; ?>/picture"/><strong><?php echo $friend['name'];?></strong><br />
<input type="checkbox" name="friendids[]" class="facebookfriendsrequired fbfriendids" value="<?php echo $friend['id'];?>" />
</li>
<?php } ?>
</ul>
<input type="button" name="next" id="next"/>
</form>
from fcbklistselection.
It for the version that you are using of jquery, fcbkListSelection need 1.2.x if you put other up dosen't work.
from fcbklistselection.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fcbklistselection.