admin管理员组文章数量:1326011
I have been having trouble with my select2 forms i been up all night and cant figure it out. I have been trying to get multiselect boxes to work and I could only get the first few working. I have a feeling I got javascript erros but I cant think right now. please help me.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Select2 3.1 - Tabbing out doesn't put placeholder back - jsFiddle demo</title>
<script type='text/javascript' src='.8.3.js'></script>
<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<script type='text/javascript' src=".js"></script>
<link rel="stylesheet" type="text/css" href=".css">
<style type='text/css'>
.selectContainer {
margin: 20px;
padding: 200px;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(function(){
$('#e1').select2({
data: [{id:0, text:'Haircut Woman'}, {id:1, text:'Haircut Men'}, {id:2, text:'Haircut Children'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:4, text:'Hair Coloring'}, {id:5, text:'Tinting Semi/Permanent'}, {id:6, text:'Full Weave'}, {id:7, text:'Cap Frost'}, {id:8, text:'Partial Highlights/Lowlights'}, {id:9, text:'Single Foil'}, {id:10, text:'Color Gloss'}, {id:11, text:'Color Remove'}, {id:12, text:'Color Corrective'}, {id:13, text:'Reconstruction'}, {id:14, text:'Hair Styling'}, {id:15, text:'Shampoo and Style'}, {id:16, text:'Updo'}, {id:17, text:'Wedding Updo'}, {id:18, text:'Straightening'}, {id:19, text:'Deep Conditiong'}, {id:20, text:'Hair Texture'}, {id:21, text:'Inventive Perms'}, {id:21, text:'Body Waves'}, {id:22, text:'Hair Straightening'}, {id:23, text:'Chemical Straightening'}, {id:24, text:'Japanese Straightening'}, {id:25, text:'Karatin Blowout'}, {id:26, text:'Karatin Treatment'}, {id:27, text:'Hair Extension '}, {id:1, text:'Hair Extension Weaving'}, {id:2, text:'Single Hair Extension'}, {id:28, text:'Feather Hair Extension'}, {id:29, text:'Sparkle Extension'}],
multiple: true
});
$('#e3').select2({
data: [{id:0, text:'Gel Full Set'}, {id:1, text:'Gel Fill'}, {id:2, text:'Gel Color'}, {id:3, text:'Silk Full Set'}, {id:3, text:'Silk Fill'}, {id:3, text:'Acrylic Full Set'}, {id:3, text:'Acrylic Fill'}, {id:3, text:'Solar Full Set'}, {id:3, text:'Solar Fill'}, {id:3, text:'Solar Pink & White Fill'}, {id:3, text:'Paraffin Wax'}, {id:3, text:'Nail Art'}, {id:3, text:'3D Nail Art'}, {id:3, text:'French'}, {id:3, text:'Hand Polish Change'}],
multiple: true
});
$('#e4').select2({
data: [{id:0, text:'Derm Renew Facial'}, {id:1, text:'Thermo Plastic Facial'}, {id:2, text:'Algomask +Cooling Thermo'}, {id:3, text:'Corrective Mask Facial'}, {id:3, text:'Collagen 90'}, {id:3, text:'Sea C Spa'}, {id:1, text:'Botinol “Botox like Effect”'}, {id:2, text:'Micro-Dermabrasion Treatment'}, {id:3, text:'Home Facial'}, {id:3, text:'European Facial'}, {id:3, text:'Dark Eye Circle & Puffiness'}, {id:3, text:'Acne Treatment Facial'}, {id:3, text:'Chemical Peel Treatment'}, {id:3, text:'Skin Tags, Brown Spot'}, {id:3, text:'Freckle, Mole Removal'}],
multiple: true
});
$('#e5').select2({
data: [{id:0, text:'Eyebrow'}, {id:1, text:'Lip'}, {id:2, text:'Chin'}, {id:3, text:'Freckle, Mole Removal'}, {id:3, text:'Face'}, {id:3, text:'Half Legs'}, {id:3, text:'Full Legs'}, {id:3, text:'Under Arms'}, {id:3, text:'Half Arms'}, {id:3, text:'Full Arms'}, {id:3, text:'Bikini'}, {id:3, text:'Brazilian'}, {id:3, text:'Stomach'}, {id:3, text:'Back'}, {id:3, text:'Shoulder'}, {id:3, text:'Neck'}, {id:3, text:'Neck'}],
multiple: true
});
$('#e6').select2({
data: [{id:0, text:'Body Bronzing'}, {id:1, text:'Full Legs Bronzing'}, {id:2, text:'Sparkle Extension'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:1, text:'Haircut Men'}, {id:2, text:'Haircut Children'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}],
multiple: true
});
$('#e7').select2({
data: [{id:0, text:'Bridal Make-Up'}, {id:1, text:'Make-Up Application'}, {id:2, text:'Lash or Brow Tinting'}, {id:3, text:'Eye Lash Perm'}, {id:3, text:'Flare Eye Lash Extension'}, {id:3, text:'Single Lash Extension'}, {id:3, text:'Airbrush Make-Up'}],
multiple: true
});
$('#e8').select2({
data: [{id:0, text:'30 Minutes'}, {id:1, text:'60 Minutes'}, {id:2, text:'90'}],
multiple: true
});
$('#e9').select2({
data: [{id:2, text:'15 Minutes'}{id:0, text:'30 Minutes'}, {id:1, text:'60 Minutes'}, {id:2, text:'90 Minutes'}],
multiple: true
});
$('#e10').select2({
data: [{id:0, text:'1 Session'}, {id:1, text:'3 or More Sessions'}, {id:2, text:'6 or More Session'}],
multiple: true
});
$('#e11').select2({
data: [{id:0, text:'1 Session'}, {id:1, text:'3 or More Sessions'}, {id:2, text:'6 or More Session'}],
multiple: true
});
$('#e12').select2({
data: [{id:0, text:'Eyebrow'}, {id:1, text:'Eyebrow Hair Stroke'}, {id:2, text:'Eye Liner'}, {id:3, text:'Eye Liner Upper & Lower'}, {id:4, text:'Lip Liner'}, {id:5, text:'FUll Lip'}, {id:6, text:'COrrective'}],
multiple: true
});
});//]]>
</script>
</head>
<body>
<div class="selectContainer">
<p>
<label for="e1">Hair Service</label>
<input type="text" id="e1" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e2">Nails Service</label>
<input type="text" id="e2" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e3">Specialized Nails</label>
<input type="text" id="e3" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e4">Skin Care</label>
<input type="text" id="e4" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e5">Face & Body Waxing</label>
<input type="text" id="e5" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e6">Body Bronzing</label>
<input type="text" id="e6" placeholder="Select all that apply" />
</p>
<p>
<label for="e7">Cosmetic</label>
<input type="text" id="e1" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e8">Massage</label>
<input type="text" id="e2" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e9">Slimming & Toning Stomach Treatment</label>
<input type="text" id="e3" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e10">Body Wrap</label>
<input type="text" id="e4" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e11">Double Chin</label>
<input type="text" id="e5" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e12">Permanent Make-Up Tattooing</label>
<input type="text" id="e6" placeholder="Select all that apply" />
</p>
<br/>
</div>
</body>
</html>
I have been having trouble with my select2 forms i been up all night and cant figure it out. I have been trying to get multiselect boxes to work and I could only get the first few working. I have a feeling I got javascript erros but I cant think right now. please help me.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Select2 3.1 - Tabbing out doesn't put placeholder back - jsFiddle demo</title>
<script type='text/javascript' src='http://code.jquery./jquery-1.8.3.js'></script>
<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<script type='text/javascript' src="http://ivaynberg.github./select2/select2-master/select2.js"></script>
<link rel="stylesheet" type="text/css" href="http://ivaynberg.github./select2/select2-master/select2.css">
<style type='text/css'>
.selectContainer {
margin: 20px;
padding: 200px;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(function(){
$('#e1').select2({
data: [{id:0, text:'Haircut Woman'}, {id:1, text:'Haircut Men'}, {id:2, text:'Haircut Children'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:4, text:'Hair Coloring'}, {id:5, text:'Tinting Semi/Permanent'}, {id:6, text:'Full Weave'}, {id:7, text:'Cap Frost'}, {id:8, text:'Partial Highlights/Lowlights'}, {id:9, text:'Single Foil'}, {id:10, text:'Color Gloss'}, {id:11, text:'Color Remove'}, {id:12, text:'Color Corrective'}, {id:13, text:'Reconstruction'}, {id:14, text:'Hair Styling'}, {id:15, text:'Shampoo and Style'}, {id:16, text:'Updo'}, {id:17, text:'Wedding Updo'}, {id:18, text:'Straightening'}, {id:19, text:'Deep Conditiong'}, {id:20, text:'Hair Texture'}, {id:21, text:'Inventive Perms'}, {id:21, text:'Body Waves'}, {id:22, text:'Hair Straightening'}, {id:23, text:'Chemical Straightening'}, {id:24, text:'Japanese Straightening'}, {id:25, text:'Karatin Blowout'}, {id:26, text:'Karatin Treatment'}, {id:27, text:'Hair Extension '}, {id:1, text:'Hair Extension Weaving'}, {id:2, text:'Single Hair Extension'}, {id:28, text:'Feather Hair Extension'}, {id:29, text:'Sparkle Extension'}],
multiple: true
});
$('#e3').select2({
data: [{id:0, text:'Gel Full Set'}, {id:1, text:'Gel Fill'}, {id:2, text:'Gel Color'}, {id:3, text:'Silk Full Set'}, {id:3, text:'Silk Fill'}, {id:3, text:'Acrylic Full Set'}, {id:3, text:'Acrylic Fill'}, {id:3, text:'Solar Full Set'}, {id:3, text:'Solar Fill'}, {id:3, text:'Solar Pink & White Fill'}, {id:3, text:'Paraffin Wax'}, {id:3, text:'Nail Art'}, {id:3, text:'3D Nail Art'}, {id:3, text:'French'}, {id:3, text:'Hand Polish Change'}],
multiple: true
});
$('#e4').select2({
data: [{id:0, text:'Derm Renew Facial'}, {id:1, text:'Thermo Plastic Facial'}, {id:2, text:'Algomask +Cooling Thermo'}, {id:3, text:'Corrective Mask Facial'}, {id:3, text:'Collagen 90'}, {id:3, text:'Sea C Spa'}, {id:1, text:'Botinol “Botox like Effect”'}, {id:2, text:'Micro-Dermabrasion Treatment'}, {id:3, text:'Home Facial'}, {id:3, text:'European Facial'}, {id:3, text:'Dark Eye Circle & Puffiness'}, {id:3, text:'Acne Treatment Facial'}, {id:3, text:'Chemical Peel Treatment'}, {id:3, text:'Skin Tags, Brown Spot'}, {id:3, text:'Freckle, Mole Removal'}],
multiple: true
});
$('#e5').select2({
data: [{id:0, text:'Eyebrow'}, {id:1, text:'Lip'}, {id:2, text:'Chin'}, {id:3, text:'Freckle, Mole Removal'}, {id:3, text:'Face'}, {id:3, text:'Half Legs'}, {id:3, text:'Full Legs'}, {id:3, text:'Under Arms'}, {id:3, text:'Half Arms'}, {id:3, text:'Full Arms'}, {id:3, text:'Bikini'}, {id:3, text:'Brazilian'}, {id:3, text:'Stomach'}, {id:3, text:'Back'}, {id:3, text:'Shoulder'}, {id:3, text:'Neck'}, {id:3, text:'Neck'}],
multiple: true
});
$('#e6').select2({
data: [{id:0, text:'Body Bronzing'}, {id:1, text:'Full Legs Bronzing'}, {id:2, text:'Sparkle Extension'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:1, text:'Haircut Men'}, {id:2, text:'Haircut Children'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}, {id:3, text:'Hair Trim Bang or Neck'}],
multiple: true
});
$('#e7').select2({
data: [{id:0, text:'Bridal Make-Up'}, {id:1, text:'Make-Up Application'}, {id:2, text:'Lash or Brow Tinting'}, {id:3, text:'Eye Lash Perm'}, {id:3, text:'Flare Eye Lash Extension'}, {id:3, text:'Single Lash Extension'}, {id:3, text:'Airbrush Make-Up'}],
multiple: true
});
$('#e8').select2({
data: [{id:0, text:'30 Minutes'}, {id:1, text:'60 Minutes'}, {id:2, text:'90'}],
multiple: true
});
$('#e9').select2({
data: [{id:2, text:'15 Minutes'}{id:0, text:'30 Minutes'}, {id:1, text:'60 Minutes'}, {id:2, text:'90 Minutes'}],
multiple: true
});
$('#e10').select2({
data: [{id:0, text:'1 Session'}, {id:1, text:'3 or More Sessions'}, {id:2, text:'6 or More Session'}],
multiple: true
});
$('#e11').select2({
data: [{id:0, text:'1 Session'}, {id:1, text:'3 or More Sessions'}, {id:2, text:'6 or More Session'}],
multiple: true
});
$('#e12').select2({
data: [{id:0, text:'Eyebrow'}, {id:1, text:'Eyebrow Hair Stroke'}, {id:2, text:'Eye Liner'}, {id:3, text:'Eye Liner Upper & Lower'}, {id:4, text:'Lip Liner'}, {id:5, text:'FUll Lip'}, {id:6, text:'COrrective'}],
multiple: true
});
});//]]>
</script>
</head>
<body>
<div class="selectContainer">
<p>
<label for="e1">Hair Service</label>
<input type="text" id="e1" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e2">Nails Service</label>
<input type="text" id="e2" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e3">Specialized Nails</label>
<input type="text" id="e3" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e4">Skin Care</label>
<input type="text" id="e4" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e5">Face & Body Waxing</label>
<input type="text" id="e5" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e6">Body Bronzing</label>
<input type="text" id="e6" placeholder="Select all that apply" />
</p>
<p>
<label for="e7">Cosmetic</label>
<input type="text" id="e1" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e8">Massage</label>
<input type="text" id="e2" placeholder="Select all that apply" />
</p>
<br/>
<p>
<label for="e9">Slimming & Toning Stomach Treatment</label>
<input type="text" id="e3" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e10">Body Wrap</label>
<input type="text" id="e4" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e11">Double Chin</label>
<input type="text" id="e5" placeholder="Select all that apply" />
</p>
<BR>
<p>
<label for="e12">Permanent Make-Up Tattooing</label>
<input type="text" id="e6" placeholder="Select all that apply" />
</p>
<br/>
</div>
</body>
</html>
Share
Improve this question
asked Sep 30, 2013 at 20:27
Fou SaephanFou Saephan
411 gold badge1 silver badge4 bronze badges
1
- Providing a jsfiddle of this code will make people more likely to provide an answer, as diagnosing the issue will be easier that way than looking at a Big Block of Code. – Wade Tandy Commented Sep 30, 2013 at 20:30
2 Answers
Reset to default 4Reason is a syntax error when defining the array (missing ma), you should see it in the console.
$('#e9').select2({
data: [{id:2, text:'15 Minutes'},{id:0, text:'30 Minutes'}, {id:1, text:'60 Minutes'}, {id:2, text:'90 Minutes'}],
^___ This ma was missing
multiple: true
});
Fiddle
Also make sure the id's of the last 5-6 selects are correct (seems like a copy paste issue)
After wasting more than an hour I atlast found this in Select2 Docs:
$('#profession').select2().val([1,2]).trigger("change")
here 1,2 is the value and #profession is the id of the select-option.
SHORT-SWEET-SIMPLE!
本文标签: javascriptselect2 multiselect drop downStack Overflow
版权声明:本文标题:javascript - select2 multiselect drop down - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742133204a2422253.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论