Wednesday, July 15, 2020

Copy option values of one select element to another select elements

Copy option values of one select element to another select elements



step 1: You must have a running boostrap and jquery in the your code


kindly check the link here




step 2: you must have already filled in select element in html form



this is a select list with options filled in




this is my select list with id #feederlist





<select id="feederlist" class="col-sm-10 custom-select custom-select-sm feederid1">
  <option value="Please Select Feeder">Please Select Feeder : </option>
  <option value="33004">33004 : 11KV DUMAD</option>
  <option value="33005">33005 : 11KV SANKARIA           </option>
  <option value="105100">105100 : 66KV FERTILIZER S/S           </option>
  <option value="105405">105405 : 11KV VASNA                    </option>
  <option value="105407">105407 : 11KV DASHRATH                 </option>
  <option value="105306">105306 : 11KV ASOJ                     </option>
  <option value="105400">105400 : 66KV RANOLI S/S               </option>
</select>



Step 3 : You need to have an empty select list in order to clone

this is created with id #feederlist2
<select id="feederlist2" class="col-sm-10 custom-select custom-select-sm"></select>
this select will be blank by default if you want it to fill you can fill it with some options

Step 4 : in order to clone from #feederlist to #feederlist2

apply the command


$('select#feederlist  option').clone().appendTo('#feederlist2');

No comments:

Post a Comment

How To Make Spinner dialogue in bootstrap and jquery

How to make spinner dialogue in boostrap and jquery or Please wait.... you need to have this spinner first Download This now