CFTEXTINPUTis the first tag you are going to look at that enables you to extend the basi functionality of HTML forms with special Java applets. The CFTEXTINPUTtag enables a form to include a more flexible single-line textentry field than traditional INPUTand CFINPUTtags
Among the features of this Iava-based field are the capabilities to specify the font of text inside the fields as well as the color and size.
The basic use of the tag is the same as that of INPUT.You can specify a name with the NAMEattribute, a size in number of characters with the SIZE attribute, a maximum length for the data being entered in the field with the.MAXlENGTH attribute, and a default value fo the field with the VALUEattribute
Beyond this though are the validation features of the CFTEXTINPUT tag which will be discussed in the next chapter and text formatting features which we cover here..
When a form containing fields created with CFTEXTINPUT is submitted, the value of the field is available through a form variable with a name corresponding to the name of the field. For instance, if you add a submit button to your form, you can access the values of the fields in submi t. cfm with Form. Testl, Form. Test2,Form. Test3, Form. Test4, and Form. TestS.
A final issue needs to be addressed: What happens if a browser Without Java support or with Java support disabled loads a page with a form containing a field that was created with the CFTEXTINPUT tag? As mentioned earlier, the field is actually a Java applet
Using CFSLIDER to Create Slider Controls
The next java-based form field you will look at is created with the CFSLIDER tag, This tag “builds a slider control that is ideal for selecting a value from a numerical range (such as ages, weights and sizes). Figure 15.21 shows a sample slider control.
Aside from attributes used for form validation, \ nich we will cover in Ch-: ‘<>~ 16, the CFSLIDER tag uses several attributes to control its oehavior and visual appearance. These attributes are described in the following sections
Controlling a Slider’s Behavior
A slider control’s behavior is determined by the numeric range supported by the control and the increments by which the control can change the value of the field. For instance, a control may have a numeric range from 0 to 100 but could then have an increment of 10 (which means there are 11 possible. values for the field: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, and 100) or it could have an increment of 1 (which would mean that the field has 101 possible values-every integer from 0 to 100 inclusive).
These two values are specified using the following attributes:
RANGE Specifies the left and right values of the slider range. The numbers should be separated by a comma. For instance, the range 0 to 100 (which is the default range if none is specified) is indicated with RANGEz” 0 100″ .
SCALE Specifies the increment for the control. By default the increment is 1.
Therefore, in the preceding examples, the first control with an increment of 10 would use the attributes RANGE”‘” 0,100″ SCALE=”10’ whereas the second control would use RANGE=” 0,100″ SCALE=”1″.
You need to consider some practicalities of combining range and increment settings. The basic rule is this: The left and right values of the range preferably should each be a multiple of the increment value. For instance, the range RANGE-’24 , 1<50’with an increment SCALE-12will work properly for the left value of the range: 24 is a multiple of 12. This displays as shown in the following graphic
However notice how the right value of the slider is 96, the closest multiple of 12 that is less than the specified right value of the range as shown in the following graphic.
Similarly, the same issues apply to the left value of the range. If you change the increment to SCALE=ll, then suddenly the left value of the range becomes 22, the closest multiple of 11 that is less than the specified left value of range (see the following graphic).
In addition to specifying the range and increment of a control you can also specify a default initial value using the VALUE attribute. Generally you will want to make this value a multiple of the increment within the specified range. If the value specified doesn’t meet these criteria then the slider will display the default value (even if it is out of range). But after the slider is moved then it is not possible to return it to the specified value.
By way of example, the following attributes
RANGE=”24,96″ SCALE-12 VALUE-36
work well and initially appear with the value” shown in the following graphic.