Jquery
How to select all check boxes with one click ?
Selecting multiple items from a list to process them or delete them is just one like of jquery program.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <fieldset> <div><input type="checkbox" class="checkall"> Check all</div> <div><input type="checkbox"> Checkbox 1</div> <div><input type="checkbox"> Checkbox 2</div> <div><input type="checkbox"> Checkbox 3</div> </fieldset> <script> $(document).ready(function(){ $('.checkall').click(function () { $(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked); }); }); </script> |
Here is another version which does not use fieldset
<div><input type="checkbox" class="checkall" id="select_all"> Check all</div> <div><input type="checkbox" class="case"> Checkbox 1</div> <div><input type="checkbox" class="case"> Checkbox 2</div> <div><input type="checkbox" class="case"> Checkbox 3</div> <SCRIPT language="javascript"> $(function(){ // add multiple select / deselect functionality $("#select_all").click(function () { $('.case').attr('checked', this.checked); }); // if all checkbox are selected, check the selectall checkbox // and viceversa $(".case").click(function(){ if($(".case").length == $(".case:checked").length) { $("#select_all").attr("checked", "checked"); } else { $("#select_all").removeAttr("checked"); } }); }); </SCRIPT> |
How to pass select box drop down value to multiple text boxes?
This code allow you to select dropdown value to multiple text boxes which have same name or class.
Very useful if you are creating price table and want to pass data to next page.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<select id="name" name="name">
<option value="" selected="selected">Please select...One Option</option>
<option value="Om">Om</option>
<option value="Jyoti">Jyoti</option>
<option value="Lal">Lal</option>
</select>
<input type="text" class="phonnumber" name="phonenumber" value="" readonly="readonly">
<input type="text" class="phonnumber" name="phonenumber" value="" readonly="readonly">
<script type="text/javascript">
$(document).ready(function(){
$("#name").live("change", function() {
$(".phonnumber").val($(this).find("option:selected").attr("value"));
});
});
</script> |
You can pass select drop down value to one text box without using jQuery.
<script type="text/javascript">
function explain(value){
document.getElementById("fanpage_value").value=document.getElementById("list011").value;
}
</script>
<select id="list011" name="atk" class="but" onChange="explain(this)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<form id="myform" method="post">What would you like to select
<input id="fanpage_value" value="" disabled="disabled" class="but" size="50" />
<input id="fanpage_value" value="" disabled="disabled" class="but" size="50" />
<input type="submit" name="attack" value="POST!!" class="but" />
</form> |
How to close colorbox when clicking on a link?
Colorbox is very cool js plug-in which is used by many developers.
I was creating a facebook app and had situation where i wanted to close Colorbox/popup and open new page which was not suppose to open in Colorbox.
I was searching and found really simple code which can be used in several ways with any php technology stuff.
<a onclick="parent.$.fn.colorbox.close();" href="http://www.phpmind.com" target="_top">PHPMIND.COM</a> This is good for normal site <a onclick="parent.$.fn.colorbox.close();" href="http://www.phpmind.com" target="_parent">PHPMIND.COM</a> This works when we have Iframe like in facebook apps |


