<script>
function fmouseover(obj)
{
document.all.td2.innerText=obj.innerText+"sdf"
}
function fonmouseout(obj)
{document.all.td2.innerText="";}</script>
<body>
<table>
<tr>
<td onmouseover="fmouseover(this)" onmouseout="fonmouseout(this)">something</td>
<td id="td2"></td>
</tr>
</table>
<input type="button" onclick=fb() value="oooo">
</body>
function fmouseover(obj)
{
document.all.td2.innerText=obj.innerText+"sdf"
}
function fonmouseout(obj)
{document.all.td2.innerText="";}</script>
<body>
<table>
<tr>
<td onmouseover="fmouseover(this)" onmouseout="fonmouseout(this)">something</td>
<td id="td2"></td>
</tr>
</table>
<input type="button" onclick=fb() value="oooo">
</body>
<tr>
<td onmouseover="func(this)" onmouseout="">something</td>
<td></td>
</tr>
</table>
</BODY>
function func(a){
alert("123")
alert(a.innerHTML)
alert(a.parentNode.childNodes[1].innerText="123132")
}
<tr>
<td onmouseover="document.all.td2.innerHTML='test';" onmouseout="document.all.td2.innerHTML='';">something</td>
<td></td>
</tr>
</table>
<tr>
<td onmouseover="document.all.td2.innerHTML='test';" onmouseout="document.all.td2.innerHTML='';">something</td>
<td></td>
<td id='td2'></TD>
</tr>
</table>
<tr>
<td onmouseover="func(this)" onmouseout="">something</td>
<td></td>
</tr>
</table>
</BODY>
function func(a){
alert("123")
alert(a.innerHTML)
a.parentNode.childNodes[1].innerText="123132"
}
BTW,JS内可以嵌套PHP吗?
比如,在当前页面,有<form onsubmit="aFunc()">,提交这个form后,在另一个页面的一个table中的cell中写入东西
<tr>
<td>something</td>
<td><% $_POST('textName') %></td> //php
</tr>
</table>也可 <body onlody="func()">
function func(){
document.getElementById("td2").value="1231"
}<table>
<tr>
<td>something</td>
<td id="td2"></td>
</tr>
</table>
mingxuan3000(铭轩),还有各位,有什么好办法吗
谢谢mingxuan3000(铭轩)!
这是不行的
<table width="100%" height="100%">
<tr>
<td width="75%">
<table width="75%" height="100%" background="pitchf1.gif" border="0" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="6" id="goalkeeper1">守门员一</td>
<td id="guard1">后卫一</td>
<td id="midfield1">中场一</td>
<td id="front1" rowspan="2">前锋一</td>
</tr>
<tr>
<td id="guard2">后卫二</td>
<td id="midfield2">中场二</td>
<td id="front2" rowspan="2">前锋二</td>
</tr>
<tr>
<td id="guard3">后卫三</td>
<td id="midfield3">中场三</td>
<td id="front3" rowspan="2">前锋三</td>
</tr>
<tr>
<td id="guard4">后卫四</td>
<td id="midfield4">中场四</td>
</tr>
<tr>
<td id="guard5">后卫五</td>
<td id="midfield5">中场五</td>
</tr>
<tr>
<td id="guard6">后卫六</td>
<td id="midfield6">中场六</td>
</tr>
</table>
</td>
<td width="25%">
<form name="poll" action="<?php echo $PHP_SELF; ?>" method="post" onsubmint="process()">
<select name="goalkeeper" language="JavaScript" onchange="">
<option value="" selected>守门员</option>
<option value="goalkeeper1" onclick="document.getElementById('goalkeeper1').value='goalkeeper1'">goalkeeper1</option>
<option value="" onclick="document.getElementById('goalkeeper1').value='goalkeeper2'">goalkeeper2</option>
<option value="" onclick="document.getElementById('goalkeeper1').value='goalkeeper3'">goalkeeper3</option>
<option value="" onclick="document.getElementById('goalkeeper1').value='goalkeeper4'">goalkeeper4</option>
</select><br />
<select name="guard" language="JavaScript" onchange="">
<option value="" selected>后卫</option>
<option value="guard1" onclick="document.getElementById('guard1').value='guard1'">guard1</option>
<option value="guard2" onclick="document.getElementById('guard2').value='guard2'">guard2</option>
<option value="guard3" onclick="document.getElementById('guard3').value='guard3'">guard3</option>
<option value="guard4" onclick="document.getElementById('guard4').value='guard4'">guard4</option>
<option value="guard5" onclick="document.getElementById('guard5').value='guard5'">guard5</option>
<option value="guard6" onclick="document.getElementById('guard6').value='guard6'">guard6</option>
</select><br />
<select name="midfield" language="JavaScript" onchange="">
<option value="" selected>中场</option>
<option value="midfield1" onclick="document.getElementById('midfield1').value='midfield1'">midfield1</option>
<option value="midfield2" onclick="document.getElementById('midfield2').value='midfield2'">midfield2</option>
<option value="midfield3" onclick="document.getElementById('midfield3').value='midfield3'">midfield3</option>
<option value="midfield4" onclick="document.getElementById('midfield4').value='midfield4'">midfield4</option>
<option value="midfield5" onclick="document.getElementById('midfield5').value='midfield5'">midfield5</option>
<option value="midfield6" onclick="document.getElementById('midfield6').value='midfield6'">midfield6</option>
</select><br />
<select name="front" language="JavaScript" onchange="">
<option value="" selected>前锋</option>
<option value="front1" onclick="document.getElementById('front1').value='front1'">front1</option>
<option value="front2" onclick="document.getElementById('front2').value='front2'">front2</option>
<option value="front3" onclick="document.getElementById('front3').value='front3'">front3</option>
</select><br />
<input type="submit" name="submint" value="提交" />
<input type="reset" name="reset" value="重选" />
</form>
</td>
</tr>
</table>
</body>
=================== end =================================
<option value="" selected>守门员</option>
<option value="goalkeeper11" >goalkeeper1</option>
<option value="goalkeeper12" >goalkeeper2</option> </select>
function func(a){
if(a.value=="goalkeeper11"){
document.getElementById('goalkeeper1').value='goalkeeper1'
}
}
<option>里的onclick事件不响应的
<html>
<head>
<script language="JavaScript" type="text/javascript">
function func(a)
{
if(a.value=="goalkeeper1")
document.getElementById('goalkeeper1').value='goalkeeper1';
}
</script>
</head><body>
<table><tr><td id="goalkeeper1">守门员一</td></tr></table>
<form>
<select language="JavaScript" onchange="func(this)">
<option value="goalkeeper1">goalkeeper1</option>
<option selected>sth</option>
</select>
</body>
</html>
================ codes end ======================按上面这样试了一下,还是不行呢,“守门员一”并没有被替换成“goalkeeper1”
{
if(a.value=="goalkeeper1")
document.getElementById('goalkeeper1').innerText='goalkeeper1';
}