Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript不单独处理循环中的按钮_Javascript_Php_Html_Button - Fatal编程技术网

Javascript不单独处理循环中的按钮

Javascript不单独处理循环中的按钮,javascript,php,html,button,Javascript,Php,Html,Button,我有一个循环,它从数据库中检索行并在表中输出。对于每一行,我都会生成一个按钮。因此,如果我有5行,就会出现5个按钮。当前,当我按下第一个按钮时,该功能会执行它应该执行的操作,即隐藏按钮并将“按钮按下”。我遇到的问题还可以,我按下了第一个按钮,现在我需要按下第二个按钮。当我按下第二个按钮时,它会隐藏该按钮,并且不会放置任何文本。另外,如果我先按第二个按钮,它会隐藏第一个和第二个按钮上的按钮,以前的第一个按钮现在在没有真正按下时会显示“按钮按下”。我希望每个按钮都能单独工作。可能吗 function

我有一个循环,它从数据库中检索行并在表中输出。对于每一行,我都会生成一个按钮。因此,如果我有5行,就会出现5个按钮。当前,当我按下第一个按钮时,该功能会执行它应该执行的操作,即隐藏按钮并将“按钮按下”。我遇到的问题还可以,我按下了第一个按钮,现在我需要按下第二个按钮。当我按下第二个按钮时,它会隐藏该按钮,并且不会放置任何文本。另外,如果我先按第二个按钮,它会隐藏第一个和第二个按钮上的按钮,以前的第一个按钮现在在没有真正按下时会显示“按钮按下”。我希望每个按钮都能单独工作。可能吗

function buttonpressed(button) {
   button.style.visibility = "hidden";
   document.getElementById("ChangeButton1").innerHTML="Button Pressed";
   window.open ('test2.html','newWin', 'width=400,height=400');
}


while($row = odbc_fetch_array($rs)) 
{
echo '
<tr>
<td class="td" valign="top"><p id="ChangeButton"><input type="submit" name="buttonpressed" value="buttonpressed" onclick="SendEmail(this); return false;"></p></td>
</tr>';
}
功能按钮按下(按钮){
button.style.visibility=“hidden”;
document.getElementById(“ChangeButton1”).innerHTML=“按钮按下”;
window.open('test2.html','newWin','width=400,height=400');
}
while($row=odbc\u fetch\u数组($rs))
{
回声'

'; }
您有重复的ID

相反,从HTML中删除
id=“ChangeButton”
,并将JS更改为:

button.parentNode.innerHTML = "Button Pressed";
window.open(...);

你有重复的身份证

相反,从HTML中删除
id=“ChangeButton”
,并将JS更改为:

button.parentNode.innerHTML = "Button Pressed";
window.open(...);

你有重复的身份证

相反,从HTML中删除
id=“ChangeButton”
,并将JS更改为:

button.parentNode.innerHTML = "Button Pressed";
window.open(...);

你有重复的身份证

相反,从HTML中删除
id=“ChangeButton”
,并将JS更改为:

button.parentNode.innerHTML = "Button Pressed";
window.open(...);