I have a form with radiobox
, input
(type='text
' or type='checkbox'
), textarea
... dropdown menu (select
).. and I want to show a different div depending on how much input are filled/checked. I wrote this for the input (type='text'
) selecting input id by id but how it is possible do the same thing for select
and textarea
<script type="text/javascript">
$(document).ready(function() {
$("input[id*='ebit'], input[id*='nome_progetto'], input[id*='posizione_netta'], input[id*='descrizione'], input[id*='stato_transazione']").blur(function() {
var counter=0;
$("input[id*='ebit'], input[id*='posizione_netta']").each(function(ind, val){
if($(val).val().trim()!==""){
counter=counter+2;
}
});
$("input[id*='nome_progetto'], input[id*='descrizione']").each(function(ind, val){
if($(val).val().trim()!==""){
counter++;
}
});
$("input[id*='stato_transazione']").each(function(ind, val){
if($(val).val().trim()!==""){
counter++;
}
});
$("#green_0, #green_1, #green_2, #green_3, #green_4, #green_5, #green_6, #green_7, #green_8, #green_9, #green_10, #green_11, #green_12, #green_13, #green_14, #green_15").hide();
$("#green_"+counter).show();
});
});