JavaScript页面的弹出以及查询结果的返回

本想贴一些效果图出来,但是可能涉及到所在公司的保密性问题,删去

 

===============================================================
The First Page:
//Notice the id of control , because the control is not the standard control of HTML, the builder will give another for it when buiding, e.g ctl00_newContentPlaceHolder_emailtext, we can find it in the souce of page when explored...
<script language=javascript>
 function dialog()
 {
     var nameToFind = aspnetForm.document.getElementById("ctl00_newContentPlaceHolder_textBox1").value;
     //alert(nameToFind);
     var result = window.showModalDialog("SCDList.aspx?nameToFind="+nameToFind+"","Dialog Arguments Value","dialogHeight: 300px; dialogWidth: 580px; dialogTop: 108px; dialogLeft: 514px; edge: Raised; center: Yes; help: Yes; resizable: No; status: Yes;");
     var arrayresult = result.split('+');
     aspnetForm.document.getElementById("ctl00_newContentPlaceHolder_emailtext").value = arrayresult[2];
     aspnetForm.document.getElementById("ctl00_newContentPlaceHolder_grouptext").value = arrayresult[3];
 }
</script>
 
//..............anything else
 
// To Call the JS function dialog()...
<td style="width: 295px; height: 25px;" align="left">
                <input type=text id="textBox1" runat=server style="width: 150px"/>
                <button id="Botton1" οnclick="dialog()" >SCD...</button></td>
 
 
 
=================================================================
The Second Page:
//经过查询,可以动态生成网页,如果有需要,可以用JS取到这些动态网页上的值,然后返回结果给第一张页面
//这是后台的代码
protected void Page_Load(object sender, EventArgs e)
    {
        NameToFind = Convert.ToString(Request.QueryString["nameToFind"]);
        ArrayList list = scd.ExeLdap(NameToFind);
        int i = list.Count;
        Log4netWrapper.log.Debug("NameCount:" + i.ToString());
        // Judge whether the information is in the SCD database...
        Response.Write(@"<HTML><HEAD><link rel='stylesheet' type='text/css' media='screen,projection' href='css/grid.css' />
                   <link rel='stylesheet' type='text/css' media='screen,projection' href='css/styles.css' /></HEAD><BODY>");
        Response.Write(@"<div class='portlet'>");
        Response.Write(@"<h3>SCD Search Result</h3>");
       
        if (i > 0)
        {
            // Write the dynamic HTML page...
            Response.Write("<H4>Please choose your information:</H4>");
            Response.Write(@"<table >");
           // Response.Write(@"<tr><td>Please choose your information</td></tr>");
            Response.Write(@"<tr>");
            Response.Write(@"<td >Firstname</td>");
            Response.Write(@"<td >Lastname</td>");
            Response.Write(@"<td >Email</td>");
            Response.Write(@"<td >Company</td>");
            Response.Write(@"</tr>");
            // Output every query list as rows...
            for (int index = 0; index < i; index++)
            {
                ScdResult result = new ScdResult();
                result = (ScdResult)(list[index]);
                // Get the each attribute from the ScfResult class...
                string firstname = result.GetFirstName();
                string lastname = result.GetLastName();
                string company = result.GetCompany();
                string email = result.GetEmail();
                // Create the new row with different ID...
                Response.Write(@"<tr id='tr" + index + "' οnclick='result(" + index + ")'>");
                Response.Write(@"<td width='15%' id='tr" + index + "td2'>" + firstname + @"</td>");
                Response.Write(@"<td width='15%' id='tr" + index + "td3'>" + lastname + @"</td>");
                Response.Write(@"<td width='50%' id='tr" + index + "td4'>" + email + @"</td>");
                Response.Write(@"<td width='20%' id='tr" + index + "td5'>" + company + @"</td>");
                Response.Write(@"</tr>");
            }
            Response.Write(@"</table>");
          
        }
        // If no information is in the query result...
        else
        {
            // Write the dynamic HTML page...
            Response.Write("<table><tr><td>Sorry! We can't find your information in our SCD database</td></tr>");
            Response.Write("<tr><td>You can try it again</td></tr>");
            Response.Write("<tr><td>");
            Response.Write("<button οnclick='error()'>Close the window.</button>");
            Response.Write("</td></tr>");
            Response.Write("</table>");
        }
        Response.Write(@"</DIV>");
        Response.Write(@"</BODY></HTML>");
    }
 
//前台代码
//该函数触发源是<tr></tr>的onclick()动作
 <script>
   function result(index)
   {
      //var num =get(this);
      //var num =form1.document.getElementById(get(this)).id;
      var firstname = form1.document.getElementById("tr" + index + "td2").innerText;
      var lastname = form1.document.getElementById("tr" + index + "td3").innerText;
      var email= form1.document.getElementById("tr" + index + "td4").innerText;
      var company = form1.document.getElementById("tr" + index + "td5").innerText;
      //var result = firstname+lastname+email+company;
      var result = firstname+"+"+lastname+"+"+email+"+"+company;
      window.returnValue=result;
      window.close();
   }
  
   function error()
   {
     window.close();
   }
    </script>
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值