我有以下问题。
我做了一段时间mysql_fetch_arry函数来从表中获取值。
我想在每一行,最后一个文本字段(ammount)和一个按钮(添加)。
代码如下所示:
<?php while($info = mysql_fetch_array( $data )): ?>
<td id="articlenr" class="width1left"><a href="www.google.de\<?php echo $info['articlenr'] ?>"><?php echo $info['articlenr'] ?> </a></td>
<td class="width2center"><?php echo $info['stock']. " / " .$info['minstock'] ?></td>
<?php endwhile ?>
第二行是关于文章细节,什么是有用的。
所以问题是我如何才能在按钮和每行的文本字段上执行onclick事件。
点按钮上的应该会发生:
感谢您的帮助:)
答案 0 :(得分:0)
<?php while($info = mysql_fetch_array( $data )): ?>
<td class="width1left"><a href="www.google.de\<?php echo $info['articlenr'] ?>"><?php echo $info['articlenr'] ?> </a></td>
<td class="width2center"><?php echo $info['stock']. " / " .$info['minstock'] ?></td>
<td><input type="text" id="amount<?php echo $info['articlenr'] >?"></td>
<td><input typ="button" value="add" onclick="openWindow('<?php echo $info['articlenr'] ?>');"></td>
<?php endwhile ?>
<script>
function openWindow(articlenr) {
var amount = document.getElementById('amount'+articlenr).value;
var url = ".../add.php?article="+articlenr+"&ammount="+amount;
window.open(url);
}
</script>