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:
Choose Microsoft Script Editor from the Tools
Programming... menu selection. The MSE will open, placing you in the script.js file, listing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access