function getDetail(seq) {
.......
}
window.onload=function(){
var tab = document.getElementById("tab");
for(var i=0;i <tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
tab.temp.style.backgroundColor = "";
调用另一个js函数, 有参数传入 <getDetail(seq)>
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
我希望, 在这个事件中, 可以调用getDetail的函数, 得到明细
.......
}
window.onload=function(){
var tab = document.getElementById("tab");
for(var i=0;i <tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
tab.temp.style.backgroundColor = "";
调用另一个js函数, 有参数传入 <getDetail(seq)>
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
我希望, 在这个事件中, 可以调用getDetail的函数, 得到明细
var tab = document.getElementById("tab");
for(var i=0;i <tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
tab.temp.style.backgroundColor = "";
getDetail(seq) this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
可以直接这样啊
晕,你平常是怎么把那个值传给getDetail的?
如果想传入参数的话,就先设置全局变量,然后将该变量放入该函数里
function getDetail(seq) {
.......
}
var seq;
seq='hao123';
window.onload=function(){
var tab = document.getElementById("tab");
for(var i=0;i <tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
tab.temp.style.backgroundColor = "";
getDetail(seq);
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
<script>
function getDetail(id)
{
alert(id);
}
window.onload=function(){
var tab = document.getElementById("tab");
for(var i=0;i <tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
//现在我只能给你做到这一步了,tab.rows(行id).cells(列id).innerText就能取出某个行所有列的值
//如果只有行的话就直接tab.rows(行id).innerText;
tab.temp.style.backgroundColor = "";
getDetail(tab.rows(0).innerText);
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
</script>
</head>
<body><table id="tab">
<tr><td>11111111111111111</td></tr>
<tr><td>11111111111111111</td></tr>
<tr><td>11111111111111111</td></tr>
<tr><td>22222222222222222</td></tr>
</table></body>
</html>你就是在控制一下你点击后的那个行索引,得到那个多少行就行了
现在我只是写的点击第一行获取的值,
这个应该比较齐全了,随便点击table 里的哪一行都显示出那行的所有相信信息
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<script>
function getDetail(id)
{
alert(id);
}
window.onload=function(){
var tab = document.getElementById("tab").getElementsByTagName("tr");
for(i=0;i <tab.length;i++)
{
tab[i].onclick = function(){
//alert("行:"+eval(this.rowIndex));
var count=eval(this.rowIndex);
if(tab.temp)
tab.temp.style.backgroundColor = "";
getDetail(tab[count].innerText);
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
</script>
</head>
<body><table id="tab">
<tr ><td>11111111111111111</td><td>中国</td></tr>
<tr ><td>11111111111111111</td><td>英国</td></tr>
<tr ><td>11111111111111111</td><td>法国</td></tr>
<tr ><td>22222222222222222</td><td>德国</td></tr>
</table></body>
</html>
如
<font id="va">你传进来的值</font>然后到你的函数里面取function getDetail(seq) {
.......
}
window.onload=function(){
var tab = document.getElementById("tab");
for(var i=0;i <tab.rows.length;i++)
{
tab.rows[i].onclick = function(){
if(tab.temp)
tab.temp.style.backgroundColor = "";
var v=document.getaElementByID("va").value;
getDetail(v) ;
this.style.backgroundColor = "#cccccc";
tab.temp = this;
}
}
}
就拿ASP的来说吧
<%a=1%>
<script>
var str="<%=a%>";
</script>