var xmlHttp = createXmlHttpRequestObject();

<!-- give up player 1 code -->
function getNextGiveUp1(ownerID)  {
	if (document.tradeform.giveupplayer1.options[document.tradeform.giveupplayer1.selectedIndex].value == "x")  {
		clearSelectGiveUp1();
	} else {
		processGiveUp1(ownerID);
	}
}

function processGiveUp1(ownerID)  {
	if (xmlHttp)  {
		try  {
			var player1 = document.tradeform.giveupplayer1.options[document.tradeform.giveupplayer1.selectedIndex].value;
			xmlHttp.open("GET","getdraftPlayer.php?ownerID="+ownerID+"&player1="+player1+"&player2=",true);
			xmlHttp.onreadystatechange = handleRequestStateChangeGiveUp1;
			xmlHttp.send(null);
		}
		catch (e)  {
			alert("Can't connect to the server: \n" + e.toString());
		}
	}
}

function handleRequestStateChangeGiveUp1()  {
	if (xmlHttp.readyState == 4)  {
		if (xmlHttp.status == 200)  {
			try  {
				handleServerResponseGiveUp1();
			}
			catch (e)  {
				alert("Error reading the response: " + e.toString());
			}
		} else {
			alert("There was a problem retrieving the data: \n" + xmlHttp.statusText);
		}
	}
}

function handleServerResponseGiveUp1()  {
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parsererror")  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	xmlRoot = xmlResponse.documentElement;
	valueArray = xmlRoot.getElementsByTagName("value");
	var html = "";
	clearSelectGiveUp1();
	for (var x=0;x<valueArray.length;x++)  {
		var thisOption=new Array();
		thisOption["name"] = valueArray.item(x).firstChild.data+" ("+valueArray.item(x+1).firstChild.data+")";
		x++;
		x++;
		thisOption["id"] = valueArray.item(x).firstChild.data;
		document.getElementById("giveupplayer2").options[document.getElementById("giveupplayer2").options.length] = new Option(thisOption["name"],thisOption["id"]);
	}
}

function clearSelectGiveUp1()  {
	var selectList3 = document.getElementById("giveupplayer3");
	if (selectList3.options.length != 0)  {
		while(selectList3.lastChild){
    		selectList3.removeChild(selectList3.lastChild);
		}
	}
	var selectList2 = document.getElementById("giveupplayer2");
	if (selectList2.options.length != 0)  {
		while(selectList2.lastChild){
    		selectList2.removeChild(selectList2.lastChild);
		}
	}
	document.getElementById("giveupplayer2").options[document.getElementById("giveupplayer2").options.length] = new Option("Player 2...","x");
	document.getElementById("giveupplayer3").options[document.getElementById("giveupplayer3").options.length] = new Option("Player 3...","x");
}

<!-- give up player 2 code -->
function getNextGiveUp2(ownerID)  {
	if (document.tradeform.giveupplayer2.options[document.tradeform.giveupplayer2.selectedIndex].value == "x")  {
		clearSelectGiveUp2();
	} else {
		processGiveUp2(ownerID);
	}
}

function processGiveUp2(ownerID)  {
	if (xmlHttp)  {
		try  {
			var player1 = document.tradeform.giveupplayer1.options[document.tradeform.giveupplayer1.selectedIndex].value;
			var player2 = document.tradeform.giveupplayer2.options[document.tradeform.giveupplayer2.selectedIndex].value;
			xmlHttp.open("GET","getdraftPlayer.php?ownerID="+ownerID+"&player1="+player1+"&player2="+player2,true);
			xmlHttp.onreadystatechange = handleRequestStateChangeGiveUp2;
			xmlHttp.send(null);
		}
		catch (e)  {
			alert("Can't connect to the server: \n" + e.toString());
		}
	}
}

function handleRequestStateChangeGiveUp2()  {
	if (xmlHttp.readyState == 4)  {
		if (xmlHttp.status == 200)  {
			try  {
				handleServerResponseGiveUp2();
			}
			catch (e)  {
				alert("Error reading the response: " + e.toString());
			}
		} else {
			alert("There was a problem retrieving the data: \n" + xmlHttp.statusText);
		}
	}
}

function handleServerResponseGiveUp2()  {
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parsererror")  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	xmlRoot = xmlResponse.documentElement;
	valueArray = xmlRoot.getElementsByTagName("value");
	var html = "";
	clearSelectGiveUp2();
	for (var x=0;x<valueArray.length;x++)  {
		var thisOption=new Array();
		thisOption["name"] = valueArray.item(x).firstChild.data+" ("+valueArray.item(x+1).firstChild.data+")";
		x++;
		x++;
		thisOption["id"] = valueArray.item(x).firstChild.data;
		document.getElementById("giveupplayer3").options[document.getElementById("giveupplayer3").options.length] = new Option(thisOption["name"],thisOption["id"]);
	}
}

function clearSelectGiveUp2()  {
	var selectList3 = document.getElementById("giveupplayer3");
	while(selectList3.lastChild){
    	selectList3.removeChild(selectList3.lastChild);
	}
	document.getElementById("giveupplayer3").options[document.getElementById("giveupplayer3").options.length] = new Option("Player 3...","x");
}

<!-- getting player list from initial team selection -->
function getOtherPlayers()  {
	var ownerID=document.tradeform.otherteam.options[document.tradeform.otherteam.selectedIndex];
	if (ownerID.value == "x")  {
		clearOtherPlayers();
	} else {
		processGetOtherPlayers(ownerID.value);
	}
}

function processGetOtherPlayers(ownerID)  {
	if (xmlHttp)  {
		try  {
			xmlHttp.open("GET","getdraftPlayer.php?ownerID="+ownerID+"&player1=&player2",true);
			xmlHttp.onreadystatechange = handleRequestStateChangeGetOtherPlayers;
			xmlHttp.send(null);
		}
		catch (e)  {
			alert("Can't connect to the server: \n" + e.toString());
		}
	}
}

function handleRequestStateChangeGetOtherPlayers()  {
	if (xmlHttp.readyState == 4)  {
		if (xmlHttp.status == 200)  {
			try  {
				handleServerResponseGetOtherPlayers();
			}
			catch (e)  {
				alert("Error reading the response: " + e.toString());
			}
		} else {
			alert("There was a problem retrieving the data: \n" + xmlHttp.statusText);
		}
	}
}

function handleServerResponseGetOtherPlayers()  {
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parsererror")  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	xmlRoot = xmlResponse.documentElement;
	valueArray = xmlRoot.getElementsByTagName("value");
	var html = "";
	clearOtherPlayers();
	for (var x=0;x<valueArray.length;x++)  {
		var thisOption=new Array();
		thisOption["name"] = valueArray.item(x).firstChild.data+" ("+valueArray.item(x+1).firstChild.data+")";
		x++;
		x++;
		thisOption["id"] = valueArray.item(x).firstChild.data;
		document.getElementById("gettingplayer1").options[document.getElementById("gettingplayer1").options.length] = new Option(thisOption["name"],thisOption["id"]);
	}
}

function clearOtherPlayers()  {
	var selectList3 = document.getElementById("gettingplayer3");
	if (selectList3.options.length != 0)  {
		while(selectList3.lastChild){
    		selectList3.removeChild(selectList3.lastChild);
		}
	}
	var selectList2 = document.getElementById("gettingplayer2");
	if (selectList2.options.length != 0)  {
		while(selectList2.lastChild){
    		selectList2.removeChild(selectList2.lastChild);
		}
	}
	var selectList1 = document.getElementById("gettingplayer1");
	if (selectList1.options.length != 0)  {
		while(selectList1.lastChild){
    		selectList1.removeChild(selectList1.lastChild);
		}
	}
	var selectList4 = document.getElementById("gettingdraft3round");
	if (selectList4.options.length != 0)  {
		while(selectList4.lastChild){
    		selectList4.removeChild(selectList4.lastChild);
		}
	}
	var selectList5 = document.getElementById("gettingdraft2round");
	if (selectList5.options.length != 0)  {
		while(selectList5.lastChild){
    		selectList5.removeChild(selectList5.lastChild);
		}
	}
	var selectList6 = document.getElementById("gettingdraft1round");
	if (selectList6.options.length != 0)  {
		while(selectList6.lastChild){
    		selectList6.removeChild(selectList6.lastChild);
		}
	}
	document.getElementById("gettingplayer3").options[document.getElementById("gettingplayer3").options.length] = new Option("Player 3...","x");
	document.getElementById("gettingplayer2").options[document.getElementById("gettingplayer2").options.length] = new Option("Player 2...","x");
	document.getElementById("gettingplayer1").options[document.getElementById("gettingplayer1").options.length] = new Option("Player 1...","x");
	document.getElementById("gettingdraft3round").options[document.getElementById("gettingdraft3round").options.length] = new Option("Draft pick 3...","x");
	document.getElementById("gettingdraft2round").options[document.getElementById("gettingdraft2round").options.length] = new Option("Draft pick 2...","x");
	document.getElementById("gettingdraft1round").options[document.getElementById("gettingdraft1round").options.length] = new Option("Draft pick 1...","x");
	document.getElementById("gettingdraft3year").selectedIndex=0;
	document.getElementById("gettingdraft2year").selectedIndex=0;
	document.getElementById("gettingdraft1year").selectedIndex=0;
}

<!-- get other player 2 code -->
function getNextGetting1()  {
	var ownerID=document.tradeform.otherteam.options[document.tradeform.otherteam.selectedIndex].value;
	if (document.tradeform.gettingplayer1.options[document.tradeform.gettingplayer1.selectedIndex].value == "x")  {
		clearOtherPlayers2();
	} else {
		processGetting2(ownerID);
	}
}

function processGetting2(ownerID)  {
	if (xmlHttp)  {
		try  {
			var player1 = document.tradeform.gettingplayer1.options[document.tradeform.gettingplayer1.selectedIndex].value;
			xmlHttp.open("GET","getdraftPlayer.php?ownerID="+ownerID+"&player1="+player1+"&player2=",true);
			xmlHttp.onreadystatechange = handleRequestStateChangeGetting2;
			xmlHttp.send(null);
		}
		catch (e)  {
			alert("Can't connect to the server: \n" + e.toString());
		}
	}
}

function handleRequestStateChangeGetting2()  {
	if (xmlHttp.readyState == 4)  {
		if (xmlHttp.status == 200)  {
			try  {
				handleServerResponseGetting2();
			}
			catch (e)  {
				alert("Error reading the response: " + e.toString());
			}
		} else {
			alert("There was a problem retrieving the data: \n" + xmlHttp.statusText);
		}
	}
}

function handleServerResponseGetting2()  {
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parsererror")  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	xmlRoot = xmlResponse.documentElement;
	valueArray = xmlRoot.getElementsByTagName("value");
	var html = "";
	clearOtherPlayers2();
	for (var x=0;x<valueArray.length;x++)  {
		var thisOption=new Array();
		thisOption["name"] = valueArray.item(x).firstChild.data+" ("+valueArray.item(x+1).firstChild.data+")";
		x++;
		x++;
		thisOption["id"] = valueArray.item(x).firstChild.data;
		document.getElementById("gettingplayer2").options[document.getElementById("gettingplayer2").options.length] = new Option(thisOption["name"],thisOption["id"]);
	}
}

function clearOtherPlayers2()  {
	var selectList3 = document.getElementById("gettingplayer3");
	if (selectList3.options.length != 0)  {
		while(selectList3.lastChild){
    		selectList3.removeChild(selectList3.lastChild);
		}
	}
	var selectList2 = document.getElementById("gettingplayer2");
	if (selectList2.options.length != 0)  {
		while(selectList2.lastChild){
    		selectList2.removeChild(selectList2.lastChild);
		}
	}
	document.getElementById("gettingplayer3").options[document.getElementById("gettingplayer3").options.length] = new Option("Player 3...","x");
	document.getElementById("gettingplayer2").options[document.getElementById("gettingplayer2").options.length] = new Option("Player 2...","x");
}

<!-- get other player 3 code -->
function getNextGetting2()  {
	var ownerID=document.tradeform.otherteam.options[document.tradeform.otherteam.selectedIndex].value;
	if (document.tradeform.gettingplayer2.options[document.tradeform.gettingplayer2.selectedIndex].value == "x")  {
		clearOtherPlayers3();
	} else {
		processGetting3(ownerID);
	}
}

function processGetting3(ownerID)  {
	if (xmlHttp)  {
		try  {
			var player1 = document.tradeform.gettingplayer1.options[document.tradeform.gettingplayer1.selectedIndex].value;
			var player2 = document.tradeform.gettingplayer2.options[document.tradeform.gettingplayer2.selectedIndex].value;
			xmlHttp.open("GET","getdraftPlayer.php?ownerID="+ownerID+"&player1="+player1+"&player2="+player2,true);
			xmlHttp.onreadystatechange = handleRequestStateChangeGetting3;
			xmlHttp.send(null);
		}
		catch (e)  {
			alert("Can't connect to the server: \n" + e.toString());
		}
	}
}

function handleRequestStateChangeGetting3()  {
	if (xmlHttp.readyState == 4)  {
		if (xmlHttp.status == 200)  {
			try  {
				handleServerResponseGetting3();
			}
			catch (e)  {
				alert("Error reading the response: " + e.toString());
			}
		} else {
			alert("There was a problem retrieving the data: \n" + xmlHttp.statusText);
		}
	}
}

function handleServerResponseGetting3()  {
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parsererror")  {
		throw("Invalid XML structure:\n" + xmlHttp.responseText);
	}
	xmlRoot = xmlResponse.documentElement;
	valueArray = xmlRoot.getElementsByTagName("value");
	var html = "";
	clearOtherPlayers3();
	for (var x=0;x<valueArray.length;x++)  {
		var thisOption=new Array();
		thisOption["name"] = valueArray.item(x).firstChild.data+" ("+valueArray.item(x+1).firstChild.data+")";
		x++;
		x++;
		thisOption["id"] = valueArray.item(x).firstChild.data;
		document.getElementById("gettingplayer3").options[document.getElementById("gettingplayer3").options.length] = new Option(thisOption["name"],thisOption["id"]);
	}
}

function clearOtherPlayers3()  {
	var selectList3 = document.getElementById("gettingplayer3");
	if (selectList3.options.length != 0)  {
		while(selectList3.lastChild){
    		selectList3.removeChild(selectList3.lastChild);
		}
	}
	document.getElementById("gettingplayer3").options[document.getElementById("gettingplayer3").options.length] = new Option("Player 3...","x");
}
