3
In this script below it counts checkbox marked.
How can I make it besides count, also add new fields <input type="text">
according to the quantity of checkbox marked
For example: I marked 5 box, then show 5 fields
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
var contador = function() {
var n = $( "input:enabled:checked" ).length;
$("#checkcount").text( n + (n === 1 ? " é" : " são") + " selecionadoss" );
};
contador();
$( "input[type=checkbox]" ).on( "click", contador );
}//]]>
</script>
<input type="checkbox" name="check1" checked disabled value="1">
<input type="checkbox" name="check1" value="2">
<input type="checkbox" name="check1" value="3">
<input type="checkbox" name="check1" value="4">
<input type="checkbox" name="check1" value="5">
<div id="checkcount"></div>
That’s right Samir. Just takes away a doubt I noticed that inputs are appearing on any off a <div> . how can I play the input output in a div
– Fabio Henrique
Very simple... instead of $('body'). append( place your desired div: $('your div'). append(. It was just that?
– Samir Braga
Very simple indeed, show
– Fabio Henrique