Friday, June 8, 2012

how to add value one select box to another select box


Select Branch :







<script>
function addSrcToDestListM() {
 ddlbranch = window.document.formmanage.ddlbranch;  // form name.slelect id
ddlbranch1 = window.document.formmanage.ddlbranch1;
var len = ddlbranch.length;  // alert(len);
for(var i = 0; i < ddlbranch1.length; i++) {
if ((ddlbranch1.options[i] != null) && (ddlbranch1.options[i].selected)) {
var found = false;
for(var count = 0; count < len; count++) {
if (ddlbranch.options[count] != null) {
if (ddlbranch1.options[i].text == ddlbranch.options[count].text) {
found = true;
break;
      }
   }
}

if (found != true) {


ddlbranch.options[len] = new Option(ddlbranch1.options[i].text,ddlbranch1.options[i].value);
len++;


         }
      }
   }
var ddlbranchx  = window.document.formmanage.ddlbranch;
var lenx = ddlbranchx.options.length;
if(lenx!=1){
for(var ix = (lenx-1); ix >= 0; ix--) {
if ((ddlbranchx.options[ix] != null) && (ddlbranchx.options[ix].text== "Any")) {
ddlbranchx.options[ix] = null;
}
}}
}


function deleteFromDestListM() {
var ddlbranch  = window.document.formmanage.ddlbranch;
var len = ddlbranch.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((ddlbranch.options[i] != null) && (ddlbranch.options[i].selected == true)) {
ddlbranch.options[i] = null;
      }
   }
}





</script>




<form id="form-manage" name="formmanage" method="post" action="pages/manage_inspection_officer.php">
<table width="100%" cellpadding="5" cellspacing="5">




<tr >
<td align="right" valign="top"><span class="text"> Select Branch :</span></td>
<td align="left" colspan="2" >
<table width="80%" cellspacing="0" >
<tr>
<td align="left">
   <select name="ddlbranch1" id="ddlbranch1" size="10" multiple="multiple" style="width:150px; z-index:1000000000" class="combo" >
     <option value="0">--- Select branch ---</option>
<option value="1">---  branch 1---</option>
<option value="2">---  branch 2---</option>
<option value="3">---  branch 3---</option>
<option value="4">---  branch 4---</option>
   </select>
   </td>
   <td align="left">
   <input type="button" name="Add" value=" Add " id="add"  class="myButton" style="vertical-align:top;width:110px;" onclick="javascript:addSrcToDestListM();" /><br /><br />
   <input type="button" name="Remove" value="Remove" id="remove" class="myButton" style="vertical-align:top; width:110px;" onclick="javascript:deleteFromDestListM();" /><br /><br />
   </td>
<td align="left">
<select name="ddlbranch" id="ddlbranch" size="10"  style="width:150px; z-index:1000000000" class="combo" >
   
   </select>  
 </td>


 </table>  
</td>
</tr>







</table>


</form>














No comments:

Post a Comment

If you Satisfied , Please Leave a comment