2013-11-27 67 views
0

我想表明在DIV檢查選項,每個選擇的要顯示在DIV爲了複選框的選中選項,每個選擇的

1. What is the biggest skin concern in India in your practice? 
Number in order of priority 
[] Acne       
[] Dark circles under eyes    
[] Dry skin    div is here and it will show list as per selection order 
[] Oily skin      
[] Skin color      
[] Skin tone evenness    
[] Wrinkles       

的順序如果有人選擇黝黑的皮膚,然後痤瘡我的div應該列出暗下來皮膚作爲第一和粉刺後應該來

input type="checkbox" name="skin_concern[]" id="a2" title="sc" value="Dark circles under eyes" class="validate[required] radio" 

請提供此解決方案如何,我會顯示此選擇的選項按照jQuery的選擇順序。

在此先感謝

+1

分享您的代碼! – rynhe

回答

0

如果不按照您的要求試試這個代碼,讓我知道...

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> 
<style type="text/css"> 
    .show_div{ 
     float: left; 
     width: 200px; 
     height: 200px; 
     background: lightyellow; 
     border: 1px solid #ccc; 
    } 
</style> 

<input type="checkbox" class="haircls" name="skin_concern[]" value="Acne" />&nbsp;Acne<br /> 
<input type="checkbox" class="haircls" name="skin_concern[]" value="Dark circles under eyes" />&nbsp;Dark circles under eyes<br /> 
<input type="checkbox" class="haircls" name="skin_concern[]" value="Dry skin" />&nbsp;Dry skin<br /> 
<input type="checkbox" class="haircls" name="skin_concern[]" value="Oily skin" />&nbsp;Oily skin<br /> 
<input type="checkbox" class="haircls" name="skin_concern[]" value="Skin color" />&nbsp;Skin color<br /> 
<input type="checkbox" class="haircls" name="skin_concern[]" value="Skin tone evenness" />&nbsp;Skin tone evenness<br /> 


<script type="text/javascript"> 
$('.haircls').change(function(){ 
    if($(this).is(':checked')){ 
    document.getElementById('show_div_ID').innerHTML += '<span style="float:left;width:100%;">'+ this.value +'</span>'; 
    } else { 
    $("#show_div_ID span:contains('"+this.value+"')").remove(); 
    } 
}); 
</script> 


<div class="show_div" id="show_div_ID"></div> 
+0

許多感謝你讓我的一天 – Amit

相關問題