Using PHP to update a form label

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Using PHP to update a form label

Post by JackD »

Code: Select all

 
<form>
<label id="CustInfo">xxxx</label>
<label for "dollarvalue" style="display:block">Store Points:</label>
<input  id="DollarValue" type="text" name="dollarvalue" size="12" />
</form>
 
In the above form, is it possible using php, to update the <label id="CustInfo" "xxx" value to be "George Jones" and insert the text "$12.00" into the textbox for <input id="DollarValue"... ?
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Using PHP to update a form label

Post by cpetercarter »

Presumably, you want these changes to be made after the webpage has been sent to the browser (eg in response to some user action like clicking a button). Normally, Javascript is used for this purpose.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Using PHP to update a form label

Post by AbraCadaver »

Code: Select all

<?php
$info = 'George Jones';
$value = '$12.00';
?>
<form>
<label id="CustInfo"><?php echo $info; ?></label>
<label for "dollarvalue" style="display:block">Store Points:</label>
<input  id="DollarValue" type="text" name="dollarvalue" value="<?php echo $value; ?>" size="12" />
</form>
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Re: Using PHP to update a form label

Post by JackD »

Thanks to both of you. I was afraid we would have to use JavaScript, but thought perhaps it might be possible to get the server to update the page without reloading it.
Post Reply