JavaScript Tutorial by Example

Tutorial of JavaScript by example. It is not a comprehensive. JavaScript tutorial: you are encouraged to consult books. on JavaScript to read more about the …

More PDF Content

SUGI 26: JavaScript Tutorial by Example
Page 1
Paper 32-26 JavaScript Tutorial by Example Iza Peszek, Merck & Co., Inc., Rahway, NJ ABSTRACT This paper presents a code walk-thru for a useful JavaScript application designed to construct a call for a SAS ? macro. It is intended to help you learn the basics of JavaScript by example. It is not a comprehensive JavaScript tutorial: you are encouraged to consult books on JavaScript to read more about the presented techniques. Some good references are given at the end of the paper. You can use the code “as is” without understanding HTML tags, but the paper will be easier to follow if you have some familiarity with HTML syntax. Note that the presented application is designed in such a way that SAS programmers can generate it for any macro in their library using a relatively simple (guess what?) SAS macro! INTRODUCTION The purpose of the application, which will determine its design, is to: • display the parameters of a specific SAS macro, as well as the information about the macro and about its parameters, • allow users to enter the values for the macro parameters, • perform a validation of user input, • construct a valid macro call. Since we want to gather user input, we are going to use FORM FIELDS. This approach will let us provide some default values for macro parameters or restrict the values to a finite set of specific choices. User input can be processed and validated on a client by JavaScript. We also want to display information about the macro and about its parameters. Thus, we need to separate the display area into information area and data input area The easiest way to do so is to use a FRAMESET containing a Top Frame (information window) and a Bottom Frame (parameter setting window). It is logical to display the information about the macro at the start of the application, and the information about an individual parameter at the time the user is working with this parameter – i.e., when the cursor is inside the parameter’s field. This roughly defines a draft of the application structure. Next we will take care of the implementation details. Figure 1 presents a snapshot of the application window. FRAMESET The application consists of three HTML documents: parent frameset, top frame, and bottom frame. Let us start with the parent document. It defines a frameset with two frames, named “topframe” and “bottomframe”. By naming the frames, we will be able to refer to them from within our JavaScript code. The frameset reserves 25% of the display area for the top frame and suppresses the borders, so the displayed document does not look fragmented. We also define the source documents for the frames. </nobr> macro call maker for dohtml</nobr>

Download JavaScript Tutorial by Example pdf from www2.sas.com, 7 pages, 96.05KB.
Related Books

2 Responses to “JavaScript Tutorial by Example”

  1. good

Leave a Reply