Creating the supporting command files for user input

The addDynamicSource() function contains the command dw.popupCommand("MyDatasrouce_Variable"), which opens a dialog box for the user to enter a specific variable name. However, you still need to create the dialog box for MyDatasource Variable.

To provide a dialog box for the user, you must create a new set of command files: a command definition file in HTML and a command implementation file in JavaScript (for more information about command files, see ).

The command definition file tells Adobe Dreamweaver the location of the supporting implementation JavaScript files as well as the form for the dialog box that the user sees. The supporting JavaScript file determines the buttons for the dialog box and how to assign the user input from the dialog box.

To create the command definition file:

  1. Create a new blank file.
  2. Enter the following:
    <!DOCTYPE HTML SYSTEM "-//Adobe//DWExtension layout-engine 5.0//dialog"><html><head><title>MyDatasource Variable</title><script src="MyDatasource_Variable.js"></script><SCRIPT SRC="../Shared/MM/Scripts/CMN/displayHelp.js"></SCRIPT><SCRIPT SRC="../Shared/MM/Scripts/CMN/string.js"></SCRIPT><link href="../fields.css" rel="stylesheet" type="text/css"></head><body><form> <div ALIGN="center">  <table border="0" cellpadding="2" cellspacing="4"> <tr>  <td align="right" valign="baseline" nowrap>Name:</td> <td valign="baseline" nowrap>  <input name="theName" type="text" class="medTField"> </td> </tr> </table> </div></form></body></html>
  3. Save the file as MyDatasource_Variable.htm in the Configuration/Commands folder.

    NOTE

    The file MyDatasource_Variable.js is the implementation file that you create in the next procedure.

To create the supporting JavaScript file:

  1. Create a new blank file.
  2. Enter the following:
    //******************* API **********************function commandButtons(){ return new Array(MM.BTN_OK,"okClicked()",MM.BTN_Cancel,"window.close()");}//***************** LOCAL FUNCTIONS ******************function okClicked(){ var nameObj = document.forms[0].theName; if (nameObj.value) { if (IsValidVarName(nameObj.value)) { MM.MyDatasourceContents = nameObj.value; MM.retVal = "OK"; window.close(); } else { alert(nameObj.value + " " + MM.MSG_InvalidParamName); } } else { alert(MM.MSG_NoName); }}
  3. Save the file as MyDatasource_Variable.js in the Configuration/Commands folder.