1个回答
推荐于2016-08-17
展开全部
给个例子你,两个页面,一个是主页面,点击文本框的时候弹出第二个页面,弹出页面里有一个下拉列表选择,当选择一个值后,自己关闭,第一个页面文本框里就已经有选择值了。本地测试时,允许运行JavaScript。 1.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<script type="text/javascript">
<!--
function openwin(url,wwidth,wheight)
{
var x=(screen.Width-wwidth)/2;
var y=(screen.Height-wheight)/2;
window.open(url, 'upload_photo', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width='+wwidth+', height='+wheight+', left='+x+', top='+y);
}
//-->
</script>
</head> <body>
<input type="text" id="values" name="values" onclick="openwin('2.html',300,200)" />
</body>
</html>
2. html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<script type="text/javascript">
function selectvalue(values)
{
opener.document.getElementById('values').value=values;
window.close();
}
</script>
</head> <body>
<select id="selectlist" onchange="selectvalue(this.value)">
<option value="" selected="selected">请选择值</option>
<option value="值1">值1</option>
<option value="值2">值2</option>
<option value="值3">值3</option>
<option value="值4">值4</option>
</select>
</body>
</html>
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<script type="text/javascript">
<!--
function openwin(url,wwidth,wheight)
{
var x=(screen.Width-wwidth)/2;
var y=(screen.Height-wheight)/2;
window.open(url, 'upload_photo', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width='+wwidth+', height='+wheight+', left='+x+', top='+y);
}
//-->
</script>
</head> <body>
<input type="text" id="values" name="values" onclick="openwin('2.html',300,200)" />
</body>
</html>
2. html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<script type="text/javascript">
function selectvalue(values)
{
opener.document.getElementById('values').value=values;
window.close();
}
</script>
</head> <body>
<select id="selectlist" onchange="selectvalue(this.value)">
<option value="" selected="selected">请选择值</option>
<option value="值1">值1</option>
<option value="值2">值2</option>
<option value="值3">值3</option>
<option value="值4">值4</option>
</select>
</body>
</html>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询