I’m new to PHP, and building a page that displays a customer order form (collects name, address, email, etc).
I’d like to add a default value to the part that displays the input box for Email Notifications, but can’t figure out the syntax well enough to know where it should go:
<tr>
<td valign="top" class="<? $form->FieldClass('notifications');?>">Email Notifications:</td>
<td valign="top" colspan="3" value="test"><? ShowText('notifications', '35'); ?></td>
</tr>
I know the individual part should be value=”email@location” but I’m not sure where it should go.
Thanks for your help.
To populate an HTML text box with a default value, use the
valueattribute.If the
ShowTextfunction is part of a web framework, then it will probably let you enter a default value for the textbox (for example, as a third parameter to the function). Otherwise, you’ll have to inspect the source of this function and modify it as needed.The
<td>tag is used for defining a table cell. In practice, people often use tables to position elements on a page, although this is not their intended purpose. Tables don’t have anything to do with form fields, but are often used to position form fields on a page.Tip: It’s good practice to use the long version of the PHP opening tag (
<?php) instead of the short version (<?). A web server only supports the short version if the PHP installation is configured to do so. By using the long version, you don’t have to worry about whether the server has this configuration parameter set or not (it makes your scripts more portable).