javascript中关于函数里取值的问题 用一个数组来实现,传到function(a[i])里,然后读取a[i] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 每一个框都写一个form<form method="post"><input type=hidden id="a"></form><form method="post"><input type=hidden id="b"></form> <table> <tr> <td><input type="hidden" name="hid" value="11" /></td> <td><input type="button" value="look" onclick="getValue(this)" /></td> </tr> <tr> <td><input type="hidden" name="hid" value="22" /></td> <td><input type="button" value="look" onclick="getValue(this)" /></td> </tr> <tr> <td><input type="hidden" name="hid" value="33" /></td> <td><input type="button" value="look" onclick="getValue(this)" /></td> </tr> <tr> <td><input type="hidden" name="hid" value="44" /></td> <td><input type="button" value="look" onclick="getValue(this)" /></td> </tr></table><script>getValue = function(__thisobj){alert(__thisobj.parentNode.parentNode.childNodes(0).childNodes(0).value)};</script> 楼上,如果他不止一个input呢.那么好象就没有用了吧. 遗憾啊,我还真是两个input, 有什么办法呢 遗憾啊,我还真是两个input, 有什么办法呢---楼主你这样子 ,让我真的没有信心再为你回答问题了 你自己一点也不懂得变通吗?我已经给你写了取值方法 ,你就非想要完整答案?不要说什么新手之类的话 ,你要这样,10年过后你仍然是个新手 ,如果觉得我说的没道理,你可以无视 以PHP为例:HTML界面:<table><?php for($i = 0; $i < 10; $i++){ ?><tr> <td><input type="hidden" name="hid"+<?php echo $i;?> id = "hid"+<?php echo $i;?> value=""></td> <td><input type="button" name = "look"+<?php echo $i;?> id = "look"+<?php echo $i;?> onclick = "getValue(document.getElementById('hid'+<?php echo $i;?>))"></td></tr><?php } ?></table> 楼主你这样子 ,让我真的没有信心再为你回答问题了 你自己一点也不懂得变通吗? 我已经给你写了取值方法 ,你就非想要完整答案? 不要说什么新手之类的话 ,你要这样,10年过后你仍然是个新手 ,如果觉得我说的没道理,你可以无视 ////////////////////////////////////////////////被批评了,惭愧哦,一定不负tantaiyizu 教诲 其实这个页面,在你生成这个页面的时候可以人为加上一些规律啊。比如循环生成<input>的时候,加上个id="input1" "input2"等等这样,那个button 价格onclick函数,参数就是这个input的ID,点不同的button当然会响应不同的input.value了... 实在不好意思我javascript不太会这里是我的php部分for ($i=0; $i<$result_cnt; $i++){$tag2 = '<td align="left" class="fontl">'.$result[$i][3].'</a><input type="hidden" name="SaigaiFile'.$i.'" id="SaigaiFile'.$i.'" value="'.$result[$i][45].'"><input type="hidden" name="HaseiFile'.$i.'" id="HaseiFile'.$i.'" value="'.$result[$i][47].'"></td>'; $tag3 = '<td align="left" class="fontl">'.$result[$i][7].'年'.$result[$i][8].'月'.$result[$i][9].'日</td>'; $date=$result[$i][7].$result[$i][8].$result[$i][9]; $tag1 = '<td align="left" class="fontl"><input type="button" name="cmdOk" value=" 災害速報 " id="SaigaiFile'.$i.'" onclick = "getValue(document.getElementById(SaigaiFile'.$i.' ))"><br><input type="button" name="cmdOk1" value="発生状況図" id="HaseiFile'.$i.'" onclick = "getValue1(document.getElementById(HaseiFile'.$i.' ))"></td>'; $tag4 = '<td align="left" class="fontl">'.$result[$i][11].'</td>'; $arr[] = array( "tag1" => $tag1, "tag2" => $tag2, "tag3" => $tag3, "tag4" => $tag4);}我的js部分是function getValue(){var dizhi=document.getElementById().value;var Newweb Newweb= window.open('../saigai/Rst_Date/First_Report/'+dizhi); }请问在js中如何修改才能把值取到?? 谢谢了 在页面上将HIDEN的NAME都定义成"hiden[]",然后在JS中用document.getElementsByName(),就可以获得HIDEN的一个数组了. 登陆网站后台(php)出现几个错误,出分(或钱)请高手解决! Fatal error: Call to undefined function print_r() in E:\php\guestbook0.5\test2 一个 变量 链接自身的问题 PHP程序里边的汉字成乱码问题 为什么老说我的数组有错????? 请大家帮忙看看 紧急求助,投票系统被刷了 请教一个sql语句 php与oicq 这个时间sql语句如何写? 如何获取局域网内其他机器上面的时间戳。 php 如何将doc文件设置为只读状态 如何用PHP在网站后台对数据库进行备份?还原?
<form method="post">
<input type=hidden id="a">
</form>
<form method="post">
<input type=hidden id="b">
</form>
<table>
<tr>
<td><input type="hidden" name="hid" value="11" /></td>
<td><input type="button" value="look" onclick="getValue(this)" /></td>
</tr>
<tr>
<td><input type="hidden" name="hid" value="22" /></td>
<td><input type="button" value="look" onclick="getValue(this)" /></td>
</tr>
<tr>
<td><input type="hidden" name="hid" value="33" /></td>
<td><input type="button" value="look" onclick="getValue(this)" /></td>
</tr>
<tr>
<td><input type="hidden" name="hid" value="44" /></td>
<td><input type="button" value="look" onclick="getValue(this)" /></td>
</tr>
</table><script>
getValue = function(__thisobj){alert(__thisobj.parentNode.parentNode.childNodes(0).childNodes(0).value)};
</script>
---
楼主你这样子 ,让我真的没有信心再为你回答问题了
你自己一点也不懂得变通吗?
我已经给你写了取值方法 ,你就非想要完整答案?不要说什么新手之类的话 ,你要这样,10年过后你仍然是个新手 ,如果觉得我说的没道理,你可以无视
HTML界面:
<table>
<?php for($i = 0; $i < 10; $i++){ ?>
<tr>
<td><input type="hidden" name="hid"+<?php echo $i;?> id = "hid"+<?php echo $i;?> value=""></td>
<td><input type="button" name = "look"+<?php echo $i;?> id = "look"+<?php echo $i;?> onclick = "getValue(document.getElementById('hid'+<?php echo $i;?>))"></td>
</tr>
<?php } ?>
</table>
你自己一点也不懂得变通吗?
我已经给你写了取值方法 ,你就非想要完整答案? 不要说什么新手之类的话 ,你要这样,10年过后你仍然是个新手 ,如果觉得我说的没道理,你可以无视
////////////////////////////////////////////////
被批评了,惭愧哦,一定不负tantaiyizu 教诲
这里是我的php部分
for ($i=0; $i<$result_cnt; $i++){
$tag2 = '<td align="left" class="fontl">'.$result[$i][3].'</a>
<input type="hidden" name="SaigaiFile'.$i.'" id="SaigaiFile'.$i.'" value="'.$result[$i][45].'">
<input type="hidden" name="HaseiFile'.$i.'" id="HaseiFile'.$i.'" value="'.$result[$i][47].'"></td>';
$tag3 = '<td align="left" class="fontl">'.$result[$i][7].'年'.$result[$i][8].'月'.$result[$i][9].'日</td>';
$date=$result[$i][7].$result[$i][8].$result[$i][9];
$tag1 = '<td align="left" class="fontl">
<input type="button" name="cmdOk" value=" 災害速報 " id="SaigaiFile'.$i.'" onclick = "getValue(document.getElementById(SaigaiFile'.$i.' ))">
<br>
<input type="button" name="cmdOk1" value="発生状況図" id="HaseiFile'.$i.'" onclick = "getValue1(document.getElementById(HaseiFile'.$i.' ))"></td>';
$tag4 = '<td align="left" class="fontl">'.$result[$i][11].'</td>';
$arr[] = array( "tag1" => $tag1,
"tag2" => $tag2,
"tag3" => $tag3,
"tag4" => $tag4);
}我的js部分是
function getValue(){var dizhi=document.getElementById().value;var Newweb
Newweb= window.open('../saigai/Rst_Date/First_Report/'+dizhi); }
请问在js中如何修改才能把值取到?? 谢谢了