I have the following issue:
1) I have DropDown1 with some names of cars.
2) I have DropDown2 with two values:
In DropDown2, the following should happen on select of each values:
a) On selecting UserInput, the left hand side multiselect box should get hidden and in the same place, a textbox should appear. User can write any car name in the text box and then use the left to right button to move that value to right hand side select box. Right to left button should be disable in this case.
b) On selecting AutoPopulate, a multiselect box should appear on left hand side in the same place as the textbox and the textbox should get hidden. The multiselect box should get populated with car list from DropDown1. User should be able to select and move cars from left to right and right to left.
I am new to Javascript. Could someone please help me with this.
$(function(){
$("#button1").click(function(){
$("#list1 > option:selected").each(function(){
$(this).remove().appendTo("#list2");
});
});
$("#button2").click(function(){
$("#list2 > option:selected").each(function(){
$(this).remove().appendTo("#list1");
});
});
});
.bloc { display:inline-block; vertical-align:top; overflow:hidden; border:solid grey 1px; width:100px;}
.bloc select { padding:10px; margin:-5px -20px -5px -5px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
DropDown1:
<select id="DropDown1" name="DropDown1">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<br><br>
DropDown2:
<select id="DropDown2" name="DropDown2">
<option value="">-- Select --</option>
<option value="oneUsrInput">User Input</option>
<option value="twoAutoPopulate">Auto Populate</option>
</select>
<br><br>
<input type="text" id="TextBoxId" name="TextBoxId">
<div class="bloc">
<select id="list1" multiple="multiple" rows=2>
<option value=1>Option 1</option>
<option value=2>Option 2</option>
<option value=3>Option 3</option>
<option value=4>Option 4</option>
<option value=5>Option 5</option>
<option value=6>Option 6</option>
</select>
</div>
<div style="display:inline-block;">
<input id="button1" type="button" value=">>" />
<br/>
<input id="button2" type="button" value="<<" />
</div>
<div class="bloc">
<select id="list2" multiple="multiple" rows=2>
</select>
</div>