Add /Remove controls on Multple Select Option using JavaScript
<script language="javascript">
function loopSelected()
{
var PIOID = document.getElementById('PIOID');
var ExistingControl1='';
var selectedArray = new Array();
var selObj = document.getElementById('selMulPio');
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++) {
if (selObj.options[i].selected) {
ExistingControl1=ExistingControl1+"<textarea id='txt"+i+"'></textarea>";
}
}
PIOID.innerHTML=null;
PIOID.innerHTML = ExistingControl1;
}
</script>
<select name="pio[]" id="selMulPio" multiple="multiple" style="width:100px; height:120px;" onchange="loopSelected();">
<option value="1">India</option>
<option value="2">USA</option>
<option value="3">PAK</option>
</select>
<br>
<div id="PIOID"></div>
=================================
example:-
=================================
<script language="javascript">
function loopSelected()
{
var PIOID = document.getElementById('PIOID');
var ExistingControl1='';
var selectedArray = new Array();
var selObj = document.getElementById('selMulPio');
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++) {
if (selObj.options[i].selected) {
ExistingControl1=ExistingControl1+"<textarea id='txt"+i+"'></textarea>";
}
}
PIOID.innerHTML=null;
PIOID.innerHTML = ExistingControl1;
}
</script>
<select name="pio[]" id="selMulPio" multiple="multiple" style="width:100px; height:120px;" onchange="loopSelected();">
<option value="1">India</option>
<option value="2">USA</option>
<option value="3">PAK</option>
</select>
<br>
<div id="PIOID"></div>
=================================
example:-
=================================
No comments:
Post a Comment