2개의 select 상호 추출

4985 단어 html


<html>
<body>
<script type="text/javascript" language="Javascript1.1">
<!--


function moveValueToLeft(oData,oPurpose,oFleet){
	var arrSelValue = new Array();
	var arrSelText = new Array();
	var arrValueTextRelation = new Array();
	var index = 0;
	
	if (oFleet.value == "") {
	  alert("Fleet must selected.");
	  return;
	}
	
	for(var i=0; i<oData.options.length; i++){
	    if(oData.options[i].selected) {
	        arrSelValue[index] = oData.options[i].value;
	        arrSelText[index] = oData.options[i].text;
	        arrValueTextRelation[arrSelValue[index]] = oData.options[i];
	        index ++;
	    }
	}

    var order=oPurpose.options;
    var flag=true;
  	for(var i=0; i<arrSelText.length; i++) {
      	var oOption = document.createElement("option");
      	//oOption.text = arrSelText[i].substring(0,arrSelText[i].indexOf("(")+1)+" " + oFleet.options[oFleet.selectedIndex].text+" )";
      	//oOption.value = arrSelValue[i]+","+oFleet.value;
      	oOption.text = arrSelText[i];
      	oOption.value = arrSelValue[i];
      	
		for(var j=0;j<order.length;j++){
 			if(order[j].text==oOption.text)	{
	 			flag=false;
	 			break;
			}
		}
		if(flag==true){
         	oPurpose.add(oOption);
         	document.getElementById('moveTid').value = 
         			document.getElementById('moveTid').value+","+oOption.value;
		}
      	oData.removeChild(arrValueTextRelation[arrSelValue[i]]);
  	}
}
function moveValueToRight(oData,oPurpose,curFleetId,curFleetName){

	var arrSelValue = new Array();
	var arrSelText = new Array();
	var arrValueTextRelation = new Array();
	var index = 0;
	
	for(var i=0; i<oData.options.length; i++){
	    if(oData.options[i].selected) {
	        arrSelValue[index] = oData.options[i].value;
	        arrSelText[index] = oData.options[i].text;
	        arrValueTextRelation[arrSelValue[index]] = oData.options[i];
	        index ++;
	    }
	}

    var order=oPurpose.options;
    var flag=true;
  	for(var i=0; i<arrSelText.length; i++) {
      	var oOption = document.createElement("option");
      //	oOption.text = arrSelText[i].substring(0,arrSelText[i].indexOf("(")+1) + " " + curFleetName+" )";
      //	oOption.value = arrSelValue[i].substring(0,arrSelValue[i].indexOf(","));
      	oOption.text = arrSelText[i];
      	oOption.value = arrSelValue[i];
		for(var j=0;j<order.length;j++){
 			if(order[j].text==oOption.text)	{
	 			flag=false;
	 			break;
			}
		}
		if(flag==true){
         	oPurpose.add(oOption);
		}
      	oData.removeChild(arrValueTextRelation[arrSelValue[i]]);
  	}
}
//-->
</script>

<form name="fm" >
			
	
  <table border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="#f1f1f1" height="200">
<tr>
			
      <td width="21%">select1</td> 
			
      <td width="6%">&nbsp;</td>
			
      <td width="73%"</td>
</tr>
<tr>			
      <td width="21%"> 
        <select name="availableTruckList" id="availableTruckList" size="8" style="width:220px">
		</select>
</td>
			
      <td width="6%"> 
        <div align="center">
					
          <input name="rightArrowBut" value="&gt;&gt;&gt;&gt;" type="button" 
onclick="javascript:moveValueToRight(availableTruckList,currentTruckList,'${fleet.fleetId }','${fleet.fleetName }');"  />
		</div>
		<br>
		<div align="center">
          <input name="Submit" value="&lt;&lt;&lt;&lt;" type="button"
onclick="javascript:moveValueToLeft(currentTruckList,availableTruckList,fleetList);" />
		</div>
	  </td>
			
       <td width="73%"> 
	        <select name="currentTruckList" id="currentTruckList"  size="8" style="width:220px">
	        </select>
	</td>
	</tr>
</table>
	
</form>
  		
	
</body></html>

좋은 웹페이지 즐겨찾기