﻿function addItem(oSelect,sValue){
	oSelect.options[oSelect.options.length] = new Option(sValue,sValue);
}
function clsItem(oSelect){
	for (m=oSelect.options.length-1;m>0;m--)
		oSelect.options[m]=null
}
function addItems(oSelect,sValues,sSplit){
	var aValue = sValues.split(sSplit);
	oSelect.options[0] = new Option("[请选择]","");
	oSelect.disabled = false;
	for(i=0;i<aValue.length;i++)
		oSelect.options[i+1] = new Option(aValue[i].split("^")[0],aValue[i].split("^")[1]);
}
		
function rfSelect(sItemID)
{
    document.getElementById("hdTmp").value = sItemID;
    var strID = getSelectValue(document.getElementById(sItemID));
	if(strID == "")
	{
	    return;
	}
    var url = "/ax/getSSXChild.aspx?D="+strID;
    
    var callback = rfSelect_callback ;
	var data = '' ;
	Request.reSend(url,data,callback) ;		
}
function setSelect(sItemID,sTxt)
{
    document.getElementById("hdTmp").value = sItemID;
    var url = "/ax/getSSXChild.aspx?N="+sTxt;
    var callback = rfSelect_callback ;
	var data = '' ;
	Request.reSend(url,data,callback) ;	
}

function rfSelect_callback(httpObj)
{
	if(httpObj == null)	return;
	var strS = httpObj.responseText;
	var sItemID = document.getElementById("hdTmp").value;
	var sChildID;
	if(sItemID == "")sChildID = "stSheng";
	if(sItemID == "stSheng")sChildID = "stCity";
	if(sItemID == "stCity")sChildID = "stXian";

	var o = document.getElementById(sChildID);
	//o.disabled = true;
	clsItem(o);
	addItems(o,strS,"|");
}

function getSelectValue(o)
{
   var t = "";
   for(var i=0;i<o.options.length;i++)
	{
		if(o.options[i].selected){
			t = o.options[i].value;
			break;
		}
	}
	return t; 
}
function getSelectText(o)
{
   var t = "";
   for(var i=0;i<o.options.length;i++)
	{
		if(o.options[i].selected){
			t = o.options[i].text;
			break;
		}
	}
	return t; 
}

function setSelectForText(o,t)
{
   for(var i=0;i<o.options.length;i++)
	{
		if(o.options[i].text == t)
	    {
			o.options[i].selected = true;
			break;
		}
	}
}
