例一:<table border="1" width="25%" id="table1" height="107">
<tr>
<td background="Water.jpg" id="pic" onclick="this.background=this.background=='xxx.jpg'?'Water.jpg':'xxx.jpg'"> </td>
</tr>
</table>
<tr>
<td background="Water.jpg" id="pic" onclick="this.background=this.background=='xxx.jpg'?'Water.jpg':'xxx.jpg'"> </td>
</tr>
</table>
例二:<table border="1" width="25%" id="table1" height="107">
<tr>
<td background="Water.jpg" id="pic"> </td>
</tr>
</table>
<input type=button value="改变" onclick="document.all.pic.background='xxx.jpg'">
这是是我原来写的个函数,也是不行。
function f_KsPicPath(tmpPic)
{
var picpath;
picpath="kspic/"+tmpPic;
window.document.all('pic').background=picpath;
return picpath;
}
请大家再帮忙看看,这个函数该如何写?
<tr>
<td background="xiance/1.jpg" id="pic" onclick="path('xiance/2.jpg')"></td>
</tr>
</table>
<script>
function path(p){
pic.style.backgroundImage="url("+p+")"
}
</script>//
HOHO~~~~~给分~~~
{
var picpath;
picpath= "kspic/ "+tmpPic;
pic.style.backgroundImage= "url( "+picpath+ ") ;
return picpath;
}
我这样试过也不行。错误提示:'pic.style'为空或者不是对象
我上面一个没有问题的撒<table border="1" width="25%" id="table1" height="107">
<tr>
<td background="xiance/1.jpg" id="pic" onclick="f_KsPicPath('2.jpg')"> </td>
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
function f_KsPicPath(tmpPic){
var picpath
picpath= "xiance/"+tmpPic
pic.style.backgroundImage="url("+picpath+")"
} //-->
</SCRIPT>复制我这个不会错!!!
function f_KsPicPath(tmpPic)
{
var picpath;
picpath="kspic/"+tmpPic;
alert(picpath);
window.document.all('kspic').background=picpath;
return picpath;
}
</script>在这个单元格的OnClick事件中调用没有问题<table border="1" width="23%" id="table1" height="228">
<tr>
<td background="image/whiteT.gif" id="kspic" onclick="return f_KsPicPath('image/blackT.gif')"> </td>
</tr>
</table>但是在<%
Dim KsRst
Set KsRst = Server.CreateObject("ADODB.RecordSet")
KsRst.Open "Select * From KsInfo Order By KSNO",AdoCon,3,3%>
<select size="1" name="Ksno" style = "width:130" onchange="return f_KsPicPath(this.options[this.selectedIndex].innerText);">
<%
For i=1 To KsRst.RecordCount
mKsno2 = KsRst("KSNO")%>
<option value="<% =mKsno2 %>" <% If CLng(mKsno2) = CLng(mKsno) Then %>Selected<% End If %>><% =KsRst("KSPath") & "" %></option>
<%
KsRst.MoveNext
Next
KsRst.Close
Set KsRst = Nothing
%>
</select>在下拉框的OnChange事件中调用不能成功,请大伙继续关注,该如何解决?