Here I write code for select from dropdown and insert into new input box.
HTML:
<td>
<select name="registration_survey_no1[]" id="registration_survey_no1" style="width:180px;" onchange="addsurvey()" >
<option value=0> Select Survey~~Resurveyno </option>
<option value=1> Select Survey1~~Resurveyno1 </option>
<option value=2> Select Survey2~~Resurveyno2 </option>
<option value=3> Select Survey3~~Resurveyno3 </option>
<option value=4> Select Survey4~~Resurveyno4 </option>
</select>
</td>
<td>
<div class="input_fields_wrap"></div>
</td>
Javascript :
function addsurvey(){
var registration_survey_no1 = $('#registration_survey_no1').val();
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var x = 1; //initlal text box count
var i = 0 ;
var random = Date.now();
//text box increment
if(registration_survey_no1 != '0'){
x++;
$(wrapper).append('<div id="dv_'+random+'"><input type="text" value="'+registration_survey_no1+'" name="mytext[]"/><a href="#" class="remove_field" onclick="deletesurvey('+random+')">Remove</a></div>'); //add input box
//$('select[name^="input_fields_wrap"]').eq(1).focus();
$('#registration_survey_no1').trigger("chosen:updated");
//document.getElementsByName('registration_survey_no1['+i+']')[0].focus();
}
}
function deletesurvey(id){
var divid = "dv_"+id;
var element = document.getElementById(divid);
element.parentNode.removeChild(element);
}
HTML:
<td>
<select name="registration_survey_no1[]" id="registration_survey_no1" style="width:180px;" onchange="addsurvey()" >
<option value=0> Select Survey~~Resurveyno </option>
<option value=1> Select Survey1~~Resurveyno1 </option>
<option value=2> Select Survey2~~Resurveyno2 </option>
<option value=3> Select Survey3~~Resurveyno3 </option>
<option value=4> Select Survey4~~Resurveyno4 </option>
</select>
</td>
<td>
<div class="input_fields_wrap"></div>
</td>
Javascript :
function addsurvey(){
var registration_survey_no1 = $('#registration_survey_no1').val();
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var x = 1; //initlal text box count
var i = 0 ;
var random = Date.now();
//text box increment
if(registration_survey_no1 != '0'){
x++;
$(wrapper).append('<div id="dv_'+random+'"><input type="text" value="'+registration_survey_no1+'" name="mytext[]"/><a href="#" class="remove_field" onclick="deletesurvey('+random+')">Remove</a></div>'); //add input box
//$('select[name^="input_fields_wrap"]').eq(1).focus();
$('#registration_survey_no1').trigger("chosen:updated");
//document.getElementsByName('registration_survey_no1['+i+']')[0].focus();
}
}
function deletesurvey(id){
var divid = "dv_"+id;
var element = document.getElementById(divid);
element.parentNode.removeChild(element);
}