更改按钮文本
Change Button Text
>我正在学习php,想为我拥有的按钮设置显示文本。 我知道您可以使用javascript更改按钮文本,但是(至少从我所看到的)适用于.onclick我希望在页面加载时更改按钮文本。 默认情况下,我的页面上的按钮文本在加载时显示Submit Query
当我的页面加载时,我希望文本能够阅读Button on Page
有没有办法使用 php 来
1) 设置按钮文本和
2) 让它跨越表中的 2 行?
这是我正在使用的代码:
<html>
<body>
<form id="TestForm" runat="server">
<div>
<div id="calculationfields">
<table id="calculations">
<tr>
<td><label for="lblreadonly1:">Read Only 1:</label></td>
<td><input type="text" name="txtReadOnly1" maxlength="50" size="10" readonly></td>
</tr>
<tr>
<td><label for="lblreadonly2:">Read Only 2:</label></td>
<td><input type="text" name="txtReadOnly2" maxlength="50" size="10" readonly></td>
</tr>
<tr>
<td><label for="lblreadonly3:">Read Only 3:</label></td>
<td><input type="text" name="txtreadonly3" maxlength="50" size="10" readonly></td>
</tr>
<tr>
<td rowspan="2"><input type="submit" name="btn123" text="Button On Page"></td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
您应该为提交按钮使用值而不是文本
<body>
<form id="TestForm" runat="server">
<div>
<div id="calculationfields">
<table id="calculations">
<tr>
<td><label for="lblreadonly1:">Read Only 1:</label></td>
<td><input type="text" name="txtReadOnly1" maxlength="50" size="10" readonly></td>
</tr>
<tr>
<td><label for="lblreadonly2:">Read Only 2:</label></td>
<td><input type="text" name="txtReadOnly2" maxlength="50" size="10" readonly></td>
</tr>
<tr>
<td><label for="lblreadonly3:">Read Only 3:</label></td>
<td><input type="text" name="txtreadonly3" maxlength="50" size="10" readonly></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btn123" value="<?php echo 'Button On Page'; ?>" style="width:100%"></td>
</tr>
</table>
</div>
</div>
</form>
</body>
如果你总是知道你想要你的按钮说什么,你就不需要php或javascript。你可以只使用 html "value" 属性。您错误地使用了标有"文本"的属性,您应该使用"值"。将代码更新为以下内容。
将按钮 html 从以下位置更改为:
<input type="submit" name="btn123" text="Button On Page">
自:
<input type="submit" name="btn123" value="Button On Page">
编辑:
为了让你的按钮全宽。您应该使用"colspan"而不是"rowspan"。您的 td 在一行中,需要跨列。
将此代码从:
<td rowspan="2"><input type="submit" name="btn123" value="Button On Page"></td>
到(请注意,我在按钮中添加了"按钮"的 id):
<td rowspan="2"><input type="submit" id="button" name="btn123" value="Button On Page"></td>
然后添加一点 css:
#button{
width: 100%;
}
这是一个工作示例的小提琴:
https://jsfiddle.net/joeydehnert/m1ttcr86/
相关文章:
- 将文本框链接到由按钮运行的javascript公式
- JS中的按钮和文本输入
- 将文本框中的值用于按钮窗体操作上的变量
- 使用加号按钮添加多个文本框,并通过PHP提交
- 输入文本框为空时的阻止按钮asp.网络表单
- 如何通过单击html按钮获得h1的文本值
- 我想重定向点击,然后更改按钮文本,我该怎么做
- html代码需要可点击的文本按钮
- 如何在单击按钮时显示文本(按钮被<span></span>标记包围)
- 用于 asp:label 的 Javascript 更多/更少文本按钮
- 如何使用jquery消除html/文本按钮内容
- 输入文件-更改数据按钮文本的文本按钮
- “编辑文本”按钮不起作用
- “更改范围文本”按钮
- 垂直对齐文本与短长文本按钮
- 为什么文本/按钮跳转页面加载(Chrome)
- 如何在移动操作系统(android,ios)中使用Javascript触发复制文本按钮
- 为文本按钮分配Jquery列表值
- Jquery改变文本按钮显示更多/显示更少
- Javascript如何制作复制此文本按钮