客户端代码:
//根据cs名称获取该cs下所有的rmmdd
function ShowHotDestination()
{
var hotCityName="";
if (document.getElementById ("radioOtherCity").checked)
{
hotCityName=document.getElementById ("textbox_city").value;
}
else
{
var count=document.Form1.elements;
for (var i=0;i<count.length;i++)
{
if (count[i].type=="radio" && count[i].name=="cityName")
{
if (count[i].checked)
hotCityName=count[i].value
}
}
}
//alert(hotCityName);
if (hotCityName!="中文名称或拼音" && hotCityName!="")
{
document.getElementById("divShowDestinationList").style.display="block";
document.getElementById("divShowDestinationList").innerHTML="<font color='#9bbaf3'><b>正在查询该cs下的rmmdd和jd,请稍候。。。</b></font>";
showDDDiv("textbox_destination");
ShowDivDesitination(hotCityName);
}
else
{
if (document.getElementById("textbox_destination").value=="jd周围标志物")
document.getElementById("textbox_destination").value="";
}
}
var xmlhttp;
function ShowDivDesitination(hotCityName)
{
detinationOnFocus("textbox_destination"); //清除默认提示文本
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
return;
}
try
{
xmlhttp.onreadystatechange = processReqChange;
xmlhttp.open("POST","Default.aspx?hotCityName="+hotCityName,true);
xmlhttp.setRequestHeader('Connection', 'close');
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send(null);
}
catch(e)
{
document.getElementById ("divShowDestinationList").style .display ="none";
}
}
function processReqChange() {
if (xmlhttp.readyState == 4)
{
if (xmlhttp.status == 200)
{
document.getElementById("divShowDestinationList").innerHTML = xmlhttp.responseText;
}
else
{
//document.getElementById("divShowDestinationList").innerHTML="<font color='#9bbaf3'><b>正在查询该cs下的rmmdd和jd,请稍候。。。</b></font>";
}
}
}
//选择rmmdd
function chooseDestination(id)
{
document .getElementById ("textbox_destination").value=document .getElementById (id).innerText;
document .getElementById ("hidden_destination").value=document .getElementById (id).innerText;
document.getElementById ("divShowDestinationList").style .display ="none";
document.getElementById("textbox_destination").style.color="#000000"
}
function onblurDestination()
{
if (event.x<document.all.divShowDestinationList.style.posLeft || event.x>document.all.divShowDestinationList.style.posLeft+document.getElementById ("divShowDestinationList").style.posWidth)
{
document.getElementById ("divShowDestinationList").style .display ="none";
}
else
{
if (event.y<document.all.divShowDestinationList.style.posTop || event.y>document.all.divShowDestinationList.style.posTop+document.getElementById ("divShowDestinationList").style.posHeight+414)
{
document.getElementById ("divShowDestinationList").style .display ="none";
}
}
}
服务器端代码:
#region 显示所在cs的所有mdd和rmjd
private void ShowDestinationsOfCity(string cityName)
{
Etmc.App.Hotel.DataAccess.Web.NoHotelSuggestion EAHD=new Etmc.App.Hotel.DataAccess.Web.NoHotelSuggestion ();
#region 显示所在cs的所有mdd
string HotDestinations="";
DataTable dt= EAHD.SelectDestinationByCityName (cityName);
if (dt != null && dt.Rows.Count >0)
{
string tabB="<table id='TabOrderEdit' width='100%' border='0' cellSpacing='1' cellPadding='4'>";
string trB="<tr height ='22px' width ='100%' bgcolor='#FFFFFF' >";
string trBNew="<tr height ='22px' width ='100%' bgcolor='#FFFFFF' >";
string trENew="</tr>";
string trE="</tr>";
string tabE="</table>";
string tdO="";
for(int i=0;i<dt.Rows.Count;i++)
{
int j=i+1;
if (dt.Rows.Count>3 )
{
if (i%3==0)
{
trB=trB+tdO+trENew+trBNew;
tdO="";
if (dt.Rows[i]["destinationname"].ToString().IndexOf("/")>-1)
dt.Rows[i]["destinationname"]=dt.Rows[i]["destinationname"].ToString().Substring(0,dt.Rows[i]["destinationname"].ToString().IndexOf("/")).ToString();
tdO +="<td width ='33%'>"+
"<span id='span"+j.ToString()+"' name='span"+j.ToString()+"' style ='color:#4167B1;TEXT-DECORATION: underline;cursor:hand' onclick='chooseDestination(this.name);'>"+dt.Rows[i]["destinationname"].ToString()+"</span>"+
"</td>";
}
else
{
int intNum=0;
if (i==dt.Rows.Count-1)
{
intNum=i%3;
intNum=3-intNum+1;
if (dt.Rows[i]["destinationname"].ToString().IndexOf("/")>-1)
dt.Rows[i]["destinationname"]=dt.Rows[i]["destinationname"].ToString().Substring(0,dt.Rows[i]["destinationname"].ToString().IndexOf("/")).ToString();
tdO +="<td width ='33%'"+" colSpan='"+intNum.ToString()+"'>"+
"<span id='span"+j.ToString()+"' name='span"+j.ToString()+"' style ='color:#4167B1;TEXT-DECORATION: underline;cursor:hand' onclick='chooseDestination(this.name);'>"+dt.Rows[i]["destinationname"].ToString()+"</span>"+
"</td>";
}
else
{
if (dt.Rows[i]["destinationname"].ToString().IndexOf("/")>-1)
dt.Rows[i]["destinationname"]=dt.Rows[i]["destinationname"].ToString().Substring(0,dt.Rows[i]["destinationname"].ToString().IndexOf("/")).ToString();
tdO +="<td width ='33%'>"+
"<span id='span"+j.ToString()+"' name='span"+j.ToString()+"' style ='color:#4167B1;TEXT-DECORATION: underline;cursor:hand' onclick='chooseDestination(this.name);'>"+dt.Rows[i]["destinationname"].ToString()+"</span>"+
"</td>";
}
}
}
else
{
int intNum=0;
if (i==dt.Rows.Count-1)
{
intNum=i%3;
intNum=3-intNum+1;
if (dt.Rows[i]["destinationname"].ToString().IndexOf("/")>-1)
dt.Rows[i]["destinationname"]=dt.Rows[i]["destinationname"].ToString().Substring(0,dt.Rows[i]["destinationname"].ToString().IndexOf("/")).ToString();
tdO +="<td width ='33%'"+" colSpan='"+intNum.ToString()+"'>"+
"<span id='span"+j.ToString()+"' name='span"+j.ToString()+"' style ='color:#4167B1;TEXT-DECORATION: underline;cursor:hand' onclick='chooseDestination(this.name);'>"+dt.Rows[i]["destinationname"].ToString()+"</span>"+
"</td>";
}
else
{
if (dt.Rows[i]["destinationname"].ToString().IndexOf("/")>-1)
dt.Rows[i]["destinationname"]=dt.Rows[i]["destinationname"].ToString().Substring(0,dt.Rows[i]["destinationname"].ToString().IndexOf("/")).ToString();
tdO +="<td width ='33%'>"+
"<span id='span"+j.ToString()+"' name='span"+j.ToString()+"' style ='color:#4167B1;TEXT-DECORATION: underline;cursor:hand' onclick='chooseDestination(this.name);'>"+dt.Rows[i]["destinationname"].ToString()+"</span>"+
"</td>";
}
}
}
HotDestinations=tabB+trB+tdO+trE+tabE;
}
else
{
HotDestinations="<font color='#2552a2'>未找到<font color=red>"+cityName+"</font>的rmmdd!</font>";
}
#endregion
#region 显示所在cs的rmjd
string hotHotel="";
DataTable dtHotHotel= EAHD.SelectHotHotelByCityName(cityName);
if (dtHotHotel.Rows.Count > 0)
{
//hotHotel="未找到符合条件的rmjd!";
string hothotelTabStar="<table class=divhothotel><tr class=divhothoteltitle><td>jd名称</td><td align='right'>星级</td></tr>";
string hothotelBody="";
string hothotelTabEnd="</table>";
for (int i=0; i<dtHotHotel.Rows.Count; i++)
{
DateTime oNow=System.DateTime.Now;
string hrefs="../EHotel/HotelDetails.aspx?hotelId="+dtHotHotel.Rows[i]["hotelid"].ToString()+"&start="+oNow.AddDays(1).ToShortDateString()+"&end="+oNow.AddDays(2).ToShortDateString();
hothotelBody+="<tr>"
+"<td class=divhothotelname><a target ='_blank' href=/""+hrefs+"/" title='"+dtHotHotel.Rows[i]["hotelname"].ToString()+"'>"+dtHotHotel.Rows[i]["hotelname"].ToString()+"</a></td>"
+"<td class=divhothotelname align='right'>"+Etmc.App.Hotel.Common.HotelUtil.GetStarRank(dtHotHotel.Rows[i]["star"].ToString(),Application["vMapRoot"].ToString()+"/Images/",2)+"</td>"
+" </tr>";
}
hotHotel=hothotelTabStar+hothotelBody+hothotelTabEnd;
}
else
{
hotHotel="<font color='#2552a2'>未找到<font color=red>"+cityName+"</font>的热门jd!</font>";
}
#endregion
#region 合并所在cs的所有mdd和rmjd
string AllShowStr=@"<table style='BORDER-RIGHT: #9bbaf3 1px solid; BORDER-TOP: #9bbaf3 1px solid; BACKGROUND: url(../skin/default070524/menu-bo-bg.gif) repeat-x; BORDER-LEFT: #9bbaf3 1px solid; BORDER-BOTTOM: #9bbaf3 1px solid'"
+"cellSpacing='0' cellPadding='0' width='98%' align='center' border='0'>"
+"<tr>"
+"<td align='center' width='82%' height='36'><span class='tit6'> rmmdd</span></td>"
+"<td style='PADDING-RIGHT: 5px; PADDING-TOP: 5px' vAlign='top' align='right' width='18%'><IMG style='CURSOR: hand' onclick='closeDivhotDestination_hotel();'"
+"height='12' hspace='4' src='../skin/default070524/hotel-					close.gif' width='12' align='absMiddle' vspace='0'></td>"
+"</tr>"
+"<tr>"
+"<td bgColor='#ffffff' colSpan='2'>"
+"<table cellSpacing='3' cellPadding='3' width='90%' align='center' border='0'>"
+"<tr>"
+"<td id='tdHotDestination' align='center' >"+HotDestinations+"</td>"
+"</tr>"
+" </table>"
+"</td>"
+"</tr>"
+"<tr>"
+"<td style='BACKGROUND: url(../skin/default070524/menu-bo-bg.gif)' align='center' bgColor='#ffffff'"
+"colSpan='2' height='34'><span class='tit6'>rmjd </span></td>"
+"</tr>"
+"<tr>"
+"<td align='center' bgColor='#ffffff' colSpan='2'>"
+"<table cellSpacing='3' cellPadding='3' width='90%' align='center' border='0'>"
+"<tr>"
+"<td align='center' id='tdHotHotel'>"+hotHotel+"</td>"
+"</tr>"
+"</table>"
+"</td>"
+"</tr>"
+"</table>";
#endregion
Response .Write (AllShowStr);
Response .Flush();
Response .End ();
}
#endregion