注册 登录
编程论坛 ASP技术论坛

innerHTML 问题

s6gy 发布于 2007-11-14 08:49, 682 次点击

<script language="javascript">
var _tree=new Array();
var _Name=new Array();
var _Numb=new Array();
<%
dim rsTree,sqlTree
sqlTree="Select classID,Contenxt,sortNumber from [Tree] where classID=classID "
'sqlTree="Select t.[classID] as id,c.[Contenxt] as name from [Tree] as t Inner Join C_T as c on c.classID=t.classID "
'sqlTree=sqlTree&" Where t.[pass]=true Order by t.[sortNumber] asc"

'sqlTree="Select Contenxt,className from [Tree] where classID=classID"

set rsTree=conn.execute(sqlTree)
if(not rsTree.eof) then
dim ii:ii=0
do until rsTree.eof
%>
_tree[<%=ii%>]="<%=rsTree.fields(0).value%>";
_Name[<%=ii%>]="<%=rsTree.fields(1).value%>";
_Numb[<%=ii%>]="<%=rsTree.fields(2).value%>";
<%
rsTree.movenext
ii=ii+1
loop
end if
%>
function $(id){
return document.getElementById(id);
}
//获取对应的生产效益文字
function getContextInfos(){
var c=$("Tree_name1").value;
var findValu="1";
var getCCC="";
var f=false;
var i=0;
//查找
while(i<_tree.length&!f){
//alert("c="+c+",tree["+i+"]="+_tree[i]) ;
if(_tree[i]==c){
findValu=_tree[i];
getCCC=_Name[i];
getCCC1=_Numb[i];
f=true;
break;
}
i++;
}
if(f)
{
$("show_C_T_ContextInfos").innerHTML=getCCC;
$("show_C_T_ContextInfos1").innerHTML=getCCC1;

}
}
</script>


显示的

<a href="default.asp?id" ><div id="show_C_T_ContextInfos" class="TextCss"></div></a

这里 层 ID show_C_T_ContextInfos 就是显示 上面的$("show_C_T_ContextInfos").innerHTML=getCCC;


这里的show_C_T_ContextInfos 对应

现在问题是 我想把第一个弄成连接的参数传递 怎么写啊帮忙啊谢谢

4 回复
#2
s6gy2007-11-14 11:26

顶 难道没一个会的吗

#3
yms1232007-11-14 11:54
[CODE]<html>
<head>
<title>aaa</title>
<script language="javascript">
function changeLink()
{
var link=document.getElementById("show_C_T_ContextInfos");
link.setAttribute("href","http://www.baidu.com");//改变连接的地址
link.innerHTML="百度";
}
</script>
</head>
<body>
<a id="show_C_T_ContextInfos" href="http://www.sina.com.cn" >新浪</a>
<input type="button" value="动态改变连接的文字与地址" onClick="changeLink();" >
</body>
</html>[/CODE]
#4
s6gy2007-11-14 13:21
以下是引用yms123在2007-11-14 11:54:21的发言:
[CODE]<html>
<head>
<title>aaa</title>
<script language="javascript">
function changeLink()
{
$("show_C_T_ContextInfos").innerHTML=getCCC;
其实这里是把GETCCC这个变量复给他了 然后先面显示的时候就是通过<div id="show_C_T_ContextInfos"></div> 就这样就能显示了
现在是想把他放到下面当一个<a href="fff?asp?id=
$("show_C_T_ContextInfos").innerHTML=getCCC;" 就这里写不对

var link=document.getElementById("show_C_T_ContextInfos");
link.setAttribute("href","http://www.baidu.com");//改变连接的地址
link.innerHTML="百度";
}
</script>
</head>
<body>
<a id="show_C_T_ContextInfos" href="http://www.sina.com.cn" >新浪</a>
<input type="button" value="动态改变连接的文字与地址" onClick="changeLink();" >
</body>
</html>[/CODE]

[此贴子已经被作者于2007-11-14 13:26:54编辑过]

#5
yms1232007-11-15 16:28
以下是引用s6gy在2007-11-14 13:21:14的发言:


楼主的代码取得的是div层的对象,而并不是超级链接的对象
其实这个功能里个人认为没有必要为div加超级链接,直接操作
超级链接这样可以对超连接直接作改变。

1