WooBin WooYeol WooBin WooYeol - 7 months ago 19
HTML Question

Change Button Text

I am learning php and want to set the display text for a button that I have. I know that you can use javascript to change the button text,but that (at least from what I have seen) works for .onclick I want the button text to be changed when the page loads. By default the button text on my page when it loads displays

Submit Query
when my page loads I want the text to read
Button on Page




Is there a way using php to
1) set the button text and
2) have it span 2 rows in the table?

This is the code I am working with:

<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>

Answer

You should use value instead of text for your submit button

<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>

Comments