可能很容易做,但我不能解决它!
我正在尝试创建一个按钮,该按钮将从数据库中取出的行值插入到文本字段中。
<?php while ($row = mysql_fetch_array($query)) { ?> <tr>
<td><?php echo $row['mobile_number']; ?></td>
<td><input type="button" value="select" onclick="clickMe()" /></td>
</tr>
<?php } ?>
<input type="text" id="textfield" />因此,当单击"select“按钮时,textfield将被填充移动号码。
非常感谢您的提前帮助。
发布于 2013-11-04 12:50:11
试试这个:
<script>
function clickMe(number) {
document.getElementById("textfield").value = number;
// or jQuery
$("#textfield").val(number);
}
</script>
<?php while ($row = mysql_fetch_array($query)) { ?> <tr>
<td><?php echo $row['mobile_number']; ?></td>
<td><input type="button" value="select" onclick="clickMe(<?php echo $row['mobile_number']; ?>)" /></td>
</tr>
<?php } ?>
<input type="text" id="textfield" />https://stackoverflow.com/questions/19767958
复制相似问题