I have select box and one table, in select box I have 1 to 5 numbers if I select 2 from select box the table should be show 2 times.
Here is my code..
<script type="text/javascript">
$(document).ready(function(){
$('#Lessons').change(function(){
var lesNum = $('#Lessons').val();
for(k=1;k<=lesNum;k++){
$("#xyz").css("display", "block");
}
});
});
</script>
and my table code is here:
<select id="Lessons" name="Lessons">
<?php for($j=1;$j<=5;$j++):?>
<option value="<?=$j?>"><?=$j?></option>
<?php endfor;?>
</select>
<div id="xyz" style="display:none;">
<table>
//some table data goes here.
</table>
</div>
Can anyone help me out?
Here is what you can use:
HTML
JavaScript
I can recommend you to stay away from globals (
kin the loop).
And a JSFiddle example: http://jsfiddle.net/pWLhS/5/