O'Reilly logo

Beginning InfoPath™ 2003 by F. Scott Barker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.2. Working with JScript

To cover all the features and commands of JScript would take a whole book, so in this chapter the features used in the sample code will be covered. To start off, it is a good idea to discuss creating your routines.

The order of the JScript discussion will follow the flow in which the sample application will be created, thus providing meaningful examples as the discussion progresses.

12.2.1. Working with Custom Functions

Custom functions are even more straightforward. To create a custom function that doesn't return anything requires the following syntax:

function functionname
{

}

where functionname is the name of the function you specify.

Curley brackets are used to segment pieces of code. Besides using them for functions as described previously, you will use them for loops and branching code such as if statements. You can see more about if statements in the sections following.

12.2.1.1. Try It Out: Creating a Custom Function

For the purpose of the example in this chapter, you will be creating your own function called createFullName. This routine ultimately will take values set in the first name and last name fields (called txtFirstName and txtLastName). To start, open the form you created in the last Try It Out:

  1. Choose Microsoft Script Editor from the ToolsProgramming... menu selection. The MSE will open, placing you in the script.js file, listing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required