javascript里div里的内容怎么赋值到txt里面啊??????
代码如下:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xh...
代码如下:<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{font-size:14px;}
ul ,li{margin:0; padding:0; list-style:none;}
ul.line_tab { background-color:#CCCCCC; float:left; width:300px; padding:3px 0 3px 6px; margin-top:8px;}
ul.line_tab li {float: left;margin-right: 10px;}
.aa {float: left;width: 500px;height:50px;}
.dis {display:block;}
.undis {display:none;}
#bb{ width:500; margin:0 auto;}
.dd{ width:500px; padding-top:10px;}
.clear{clear:both;}
ul.line_tab li.hovertab {color:#FF0000;cursor:pointer;font-weight:bold;}
ul.line_tab li.normaltab {color:#FF0000;cursor:pointer;}
-->
</style>
</head>
<body>
<div id="bb">
<div class="aa">
<form action="">赋值到这里<input type="text" value="" id="cc" /></form>
<ul class="line_tab">
<li class="hovertab" id="one1" onclick="pub_showTab('one',1,3);">上海</li>
<li class="normaltab" id="one2" onclick="pub_showTab('one',2,3);">北京</li>
<li class="normaltab" id="one3" onclick="pub_showTab('one',3,3);">广州</li>
</ul>
</div>
<div class="clear"></div>
<div class="dd">
<div id="con_one_1" class="dis">
<p>上海de</p>
</div>
<div id="con_one_2" class="undis">
<p>北京de</p>
</div>
<div id="con_one_3" class="undis">
<p>广州de</p>
</div>
</div>
</div>
<script type="text/javascript" >
function pub_showTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
}
</script>
</body>
</html>
请问怎么样能在点击城市的名字时把值赋给上面的框里,如果上面的框可以弹出内容的话,怎么样能和下面的对应,比如在上面输入一个城市,下面的也会和它对应起来呢??? 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{font-size:14px;}
ul ,li{margin:0; padding:0; list-style:none;}
ul.line_tab { background-color:#CCCCCC; float:left; width:300px; padding:3px 0 3px 6px; margin-top:8px;}
ul.line_tab li {float: left;margin-right: 10px;}
.aa {float: left;width: 500px;height:50px;}
.dis {display:block;}
.undis {display:none;}
#bb{ width:500; margin:0 auto;}
.dd{ width:500px; padding-top:10px;}
.clear{clear:both;}
ul.line_tab li.hovertab {color:#FF0000;cursor:pointer;font-weight:bold;}
ul.line_tab li.normaltab {color:#FF0000;cursor:pointer;}
-->
</style>
</head>
<body>
<div id="bb">
<div class="aa">
<form action="">赋值到这里<input type="text" value="" id="cc" /></form>
<ul class="line_tab">
<li class="hovertab" id="one1" onclick="pub_showTab('one',1,3);">上海</li>
<li class="normaltab" id="one2" onclick="pub_showTab('one',2,3);">北京</li>
<li class="normaltab" id="one3" onclick="pub_showTab('one',3,3);">广州</li>
</ul>
</div>
<div class="clear"></div>
<div class="dd">
<div id="con_one_1" class="dis">
<p>上海de</p>
</div>
<div id="con_one_2" class="undis">
<p>北京de</p>
</div>
<div id="con_one_3" class="undis">
<p>广州de</p>
</div>
</div>
</div>
<script type="text/javascript" >
function pub_showTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
}
</script>
</body>
</html>
请问怎么样能在点击城市的名字时把值赋给上面的框里,如果上面的框可以弹出内容的话,怎么样能和下面的对应,比如在上面输入一个城市,下面的也会和它对应起来呢??? 展开
5个回答
展开全部
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{font-size:14px;}
ul ,li{margin:0; padding:0; list-style:none;}
ul.line_tab { background-color:#CCCCCC; float:left; width:300px; padding:3px 0 3px 6px; margin-top:8px;}
ul.line_tab li {float: left;margin-right: 10px;}
.aa {float: left;width: 500px;height:50px;}
.dis {display:block;}
.undis {display:none;}
#bb{ width:500; margin:0 auto;}
.dd{ width:500px; padding-top:10px;}
.clear{clear:both;}
ul.line_tab li.hovertab {color:#FF0000;cursor:pointer;font-weight:bold;}
ul.line_tab li.normaltab {color:#FF0000;cursor:pointer;}
-->
</style>
</head>
<body>
<div id="bb">
<div class="aa">
<form action="">赋值到这里<input type="text" value="" id="cc" onblur="pub_show('one',3)"/></form>
<ul class="line_tab">
<li class="hovertab" id="one1" onclick="pub_showTab('one',1,3);">上海</li>
<li class="normaltab" id="one2" onclick="pub_showTab('one',2,3);">北京</li>
<li class="normaltab" id="one3" onclick="pub_showTab('one',3,3);">广州</li>
</ul>
</div>
<div class="clear"></div>
<div class="dd">
<div id="con_one_1" class="dis">
<p>上海de</p>
</div>
<div id="con_one_2" class="undis">
<p>北京de</p>
</div>
<div id="con_one_3" class="undis">
<p>广州de</p>
</div>
</div>
</div>
<script type="text/javascript" >
function pub_showTab(name,cursel,n){
document.getElementById("cc").value=trim(document.getElementById(name+cursel).innerText);
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
}
function trim(values)//去左右边的空格
{
return values.replace(/(^\s*)|(\s*$)/g, "");
}
function pub_show(name,n){//在输入框中输入值后进行匹配
var v=trim(document.getElementById("cc").value);
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var v1=menu.innerText.replace(/(^\s*)|(\s*$)/g, "");
var con=document.getElementById("con_"+name+"_"+i);
if(v1==v){
menu.className="hovertab";
con.className="dis";
}else{
menu.className="normaltab";
con.className="undis";
}
}
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{font-size:14px;}
ul ,li{margin:0; padding:0; list-style:none;}
ul.line_tab { background-color:#CCCCCC; float:left; width:300px; padding:3px 0 3px 6px; margin-top:8px;}
ul.line_tab li {float: left;margin-right: 10px;}
.aa {float: left;width: 500px;height:50px;}
.dis {display:block;}
.undis {display:none;}
#bb{ width:500; margin:0 auto;}
.dd{ width:500px; padding-top:10px;}
.clear{clear:both;}
ul.line_tab li.hovertab {color:#FF0000;cursor:pointer;font-weight:bold;}
ul.line_tab li.normaltab {color:#FF0000;cursor:pointer;}
-->
</style>
</head>
<body>
<div id="bb">
<div class="aa">
<form action="">赋值到这里<input type="text" value="" id="cc" onblur="pub_show('one',3)"/></form>
<ul class="line_tab">
<li class="hovertab" id="one1" onclick="pub_showTab('one',1,3);">上海</li>
<li class="normaltab" id="one2" onclick="pub_showTab('one',2,3);">北京</li>
<li class="normaltab" id="one3" onclick="pub_showTab('one',3,3);">广州</li>
</ul>
</div>
<div class="clear"></div>
<div class="dd">
<div id="con_one_1" class="dis">
<p>上海de</p>
</div>
<div id="con_one_2" class="undis">
<p>北京de</p>
</div>
<div id="con_one_3" class="undis">
<p>广州de</p>
</div>
</div>
</div>
<script type="text/javascript" >
function pub_showTab(name,cursel,n){
document.getElementById("cc").value=trim(document.getElementById(name+cursel).innerText);
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
}
function trim(values)//去左右边的空格
{
return values.replace(/(^\s*)|(\s*$)/g, "");
}
function pub_show(name,n){//在输入框中输入值后进行匹配
var v=trim(document.getElementById("cc").value);
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var v1=menu.innerText.replace(/(^\s*)|(\s*$)/g, "");
var con=document.getElementById("con_"+name+"_"+i);
if(v1==v){
menu.className="hovertab";
con.className="dis";
}else{
menu.className="normaltab";
con.className="undis";
}
}
}
</script>
</body>
</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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{font-size:14px;}
ul ,li{margin:0; padding:0; list-style:none;}
ul.line_tab { background-color:#CCCCCC; float:left; width:300px; padding:3px 0 3px 6px; margin-top:8px;}
ul.line_tab li {float: left;margin-right: 10px;}
.aa {float: left;width: 500px;height:50px;}
.dis {display:block;}
.undis {display:none;}
#bb{ width:500; margin:0 auto;}
.dd{ width:500px; padding-top:10px;}
.clear{clear:both;}
ul.line_tab li.hovertab {color:#FF0000;cursor:pointer;font-weight:bold;}
ul.line_tab li.normaltab {color:#FF0000;cursor:pointer;}
-->
</style>
</head>
<body>
<div id="bb">
<div class="aa">
<form action="">赋值到这里<input type="text" value="" id="cc" onchange="pub_selectTab()" /></form>
<ul class="line_tab">
<li class="hovertab" id="one1" onclick="pub_showTab('one',1,3);">上海</li>
<li class="normaltab" id="one2" onclick="pub_showTab('one',2,3);">北京</li>
<li class="normaltab" id="one3" onclick="pub_showTab('one',3,3);">广州</li>
</ul>
</div>
<div class="clear"></div>
<div class="dd">
<div id="con_one_1" class="dis">
<p>上海de</p>
</div>
<div id="con_one_2" class="undis">
<p>北京de</p>
</div>
<div id="con_one_3" class="undis">
<p>广州de</p>
</div>
</div>
</div>
<script type="text/javascript" >
function pub_showTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
document.getElementById("cc").value = event.srcElement.innerHTML;
}
function pub_selectTab()
{
var curCity = event.srcElement.value;
var lis = document.getElementsByTagName("li");
for (var i = 0; i < lis.length; i++) {
if (lis[i].id.indexOf("one") == 0 && lis[i].innerHTML == curCity) {
lis[i].click();
}
}
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{font-size:14px;}
ul ,li{margin:0; padding:0; list-style:none;}
ul.line_tab { background-color:#CCCCCC; float:left; width:300px; padding:3px 0 3px 6px; margin-top:8px;}
ul.line_tab li {float: left;margin-right: 10px;}
.aa {float: left;width: 500px;height:50px;}
.dis {display:block;}
.undis {display:none;}
#bb{ width:500; margin:0 auto;}
.dd{ width:500px; padding-top:10px;}
.clear{clear:both;}
ul.line_tab li.hovertab {color:#FF0000;cursor:pointer;font-weight:bold;}
ul.line_tab li.normaltab {color:#FF0000;cursor:pointer;}
-->
</style>
</head>
<body>
<div id="bb">
<div class="aa">
<form action="">赋值到这里<input type="text" value="" id="cc" onchange="pub_selectTab()" /></form>
<ul class="line_tab">
<li class="hovertab" id="one1" onclick="pub_showTab('one',1,3);">上海</li>
<li class="normaltab" id="one2" onclick="pub_showTab('one',2,3);">北京</li>
<li class="normaltab" id="one3" onclick="pub_showTab('one',3,3);">广州</li>
</ul>
</div>
<div class="clear"></div>
<div class="dd">
<div id="con_one_1" class="dis">
<p>上海de</p>
</div>
<div id="con_one_2" class="undis">
<p>北京de</p>
</div>
<div id="con_one_3" class="undis">
<p>广州de</p>
</div>
</div>
</div>
<script type="text/javascript" >
function pub_showTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
document.getElementById("cc").value = event.srcElement.innerHTML;
}
function pub_selectTab()
{
var curCity = event.srcElement.value;
var lis = document.getElementsByTagName("li");
for (var i = 0; i < lis.length; i++) {
if (lis[i].id.indexOf("one") == 0 && lis[i].innerHTML == curCity) {
lis[i].click();
}
}
}
</script>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function pub_showTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
document.getElementById("cc").value=document.getElementById(name+cursel).innerHTML;
}
看下是不是你想要的效果,不是再联系我,没那么复杂嘛
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hovertab":"normaltab";
con.className=i==cursel?"dis":"undis";
}
document.getElementById("cc").value=document.getElementById(name+cursel).innerHTML;
}
看下是不是你想要的效果,不是再联系我,没那么复杂嘛
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个是比较高级的js了,要用的js的DOM框架。很复杂。我也新手。一时搞不出来。上次做过一个类似的。。。和你这个又有些不一样。。。现在上班 忙暂时没时间帮你搞。建议你看看DOM方面的js代码。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
5分不要,要2分!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询