当前位置:编程学习 > JAVA >>

点击文本框显示模式框,在模式框选中单选值,显示在文本框中


如:jsp:
      <input class="i3" type="text" name="textfield" id='select4passer${index}'onclick='open_Dialog(this);' value="中国"/>
function open_Dialog(obj)
{
 var win = window.showModalDialog("country.jsp",window,"dialogWidth=425px;dialogHeight=300px;center=yes;status=no");
  if(win != null)
  {
    //document.getElementById("parentTextBox").value = win;
   // alert(obj.id);
    var str=win.split(";");
    if(str.length>0){
    // alert(str[0]);
     //赋值
     document.getElementById(obj.id+"hidden").value=str[1];
     document.getElementById(obj.id).value=str[0];
 
    }
  }
}
country.jsp:
                
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>请选择洲  和  国家</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
   <script src="javascript/jquery.1.3.2.js" type="text/javascript"></script>
   <style type="text/css">
   .table_main { border:none;font-size:12px; background:#f3f3f3; margin-left:14px;border-top:2px #f2f7ff solid;}
   .table_main td { border-left:1px solid #fff; border-bottom:1px solid #fff; text-align:left;width:100px;height:28px; line-height:28px;}
   #div1 { height:28px; lin-height:28px; text-align:left; padding-left:15px; margin-top:20px;}
   #div1 a {color:#09f; text-decoration:none;}
    #div1 a:hover { color:#f60;}
   </style>
  </head>
 
  <body onload="checkzhou(remen);">
  <input type="hidden" id="childTextBox"/>
 
  <div id="div1">
   <a href="javascript:void(0);"  id="remen" onclick="checkzhou(this);" >热门</a>  
   <a href="javascript:void(0);" id="yzdyz" onclick="checkzhou(this);">亚洲大洋洲</a>  
  <a href="javascript:void(0);" id="ozfz" onclick="checkzhou(this);" >欧洲非洲</a>  
  <a href="javascript:void(0);" id="mz" onclick="checkzhou(this);">美洲</a>  
  </div>
  <div id="show">
 
  </div>
   
  </body>
</html>
<script>
function  checkzhou(obj){
//alert(obj.id);
var str="<table border='0' id='table1' cellspacing='0' cellpadding='0' class='table_main'><tr>";
//根据不同洲 表格里面的内容不同
var arraycountry=new Array();
if(obj.id=="remen"){
arraycountry[0]=new Array('CN','中国','china','');
arraycountry[1]=new Array('FR','法国','amarea','');
arraycountry[2]=new Array('DE','德国','china','');
arraycountry[3]=new Array('IN','印度','amarea','');
arraycountry[4]=new Array('JP','日本','china','');
arraycountry[5]=new Array('KP','韩国','amarea','');
arraycountry[6]=new Array('MO','澳门','china','');
arraycountry[7]=new Array('HK','中国香港','amarea','');
arraycountry[8]=new Array('TW','中华台湾','china','');
arraycountry[9]=new Array('UK','英国','amarea','');
arraycountry[10]=new Array('US','美国','china','');
arraycountry[11]=new Array('TH','泰国','amarea','');
arraycountry[12]=new Array('RU','俄罗斯','china','');
arraycountry[13]=new Array('AU','澳大利亚','amarea','');
arraycountry[14]=new Array('BR','巴西','china','');
arraycountry[15]=new Array('CA','加拿大','amarea','');
arraycountry[16]=new Array('EG','埃及','china','');
arraycountry[17]=new Array('ID','印度尼西亚','amarea','');
arraycountry[18]=new Array('MY','马来西亚','china','');
arraycountry[19]=new Array('MX','墨西哥','amarea','');
arraycountry[20]=new Array('MO','蒙古','china','');
arraycountry[21]=new Array('NO','挪威','amarea','');
arraycountry[22]=new Array('PK','巴基斯坦','china','');
arraycountry[23]=new Array('PH','菲律宾','amarea','');
arraycountry[24]=new Array('SE','瑞典','china','');
arraycountry[25]=new Array('GH','瑞士','amarea','');
arraycountry[26]=new Array('AE','阿联酋','china','');
arraycountry[27]=new Array('SG','新加坡','amarea','');
arraycountry[28]=new Array('NL','荷兰','china','');
arraycountry[29]=new Array('NZ','新西兰','amarea','');
arraycountry[30]=new Array('VN','越南','china','');
}
//亚洲大洋洲
else if(obj.id=="yzdyz"){
arraycountry[0]=new Array('CN','中国','CHINA','');
arraycountry[1]=new Array('IN','印度','INDIA','');
arraycountry[2]=new Array('JP','日本','JAPAN','');
arraycountry[3]=new Array('KP','韩国','','');
arraycountry[4]=new Array('MO','澳门','','');
arraycountry[5]= new Array('NZ','新西兰','NEWZEALAND','');
arraycountry[6]=new Array('HK','中国香
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,