Behaviors > Using the behavior actions that come with Dreamweaver > Set Text of Text Field

 

Set Text of Text Field

The Set Text of Text Field action replaces the content of a form's text field with the content you specify.

You can embed any valid JavaScript function call, property, global variable, or other expression in the text. To embed a JavaScript expression, place it inside braces ({}). To display a brace, precede it with a backslash (\{).

Example

The URL for this page is {window.location}, and today is {new Date()}.

To create a named text field:

1 Choose Insert > Form Objects > Text Field.
If Dreamweaver prompts you to add a form tag, click Yes. For more information, see Forms overview.
2 In the Property inspector, type a name for the text field. Make sure the name is unique on the page (don't use the same name for multiple elements on the same page, even if they're in different forms).

To use the Set Text of Text Field action:

1 Select a text field and open the Behaviors panel.
2 Click the Plus (+) button and choose Set Text > Set Text of Text Field from the Actions pop-up menu.
3 In the Set Text of Text Field dialog box, choose the target text field from the Text Field pop-up menu.
4 Enter text in the New Text field, then click OK.
5 Check that the default event is the one you want. If it isn't, choose another event from the pop-up menu.
If you don't see the events you want, change the target browser in the Show Events For pop-up menu.