|
Sybernet / Supplied Procedures Reference
Release 3.00 Mar 03, 2005 |
|
SP_HTML_INPUT creates an input field. All of the input fields that you are familar with may be created with this procedure. You can also create a TEXTAREA and SELECT list with this procedure.
It is not required that you use this procedure to create your form screens, but there are several reasons why you may want to. SP_HTML_INPUT supports pre-defined datatypes (such as int, smallint, and tinyint) which are validated on the client before these fields are submitted to your procedure. Input values are mapped so that they appear correctly on your screen. Have you ever wondered how to specify a value containing double quotes? SP_HTML_INPUT will do this for you automatically. The value passed to SELECT and TEXTAREA can be a select statement which is evaluated in real-time.
Perhaps the most compelling reason, however, is that SP_HTML_INPUT will make your input fields look and behave the same among NS4, NS7, and MSIE. NS4 correctly renders text fields with a monospace font-family. NS7 doesn't. NS7 does when when you create this field with SP_HTML_INPUT. MSIE buttons are absolutely pathetic, but look less so when created by SP_HTML_INPUT.
SP_HTML_INPUT will also raise an exception if you attempt to create an input field that it does not know about. HTML ignores invalid types and gives you a text field instead. If you misspell onFocus in an HTML form, HTML will ignore it. If you misspell onFocus when you call SP_HTML_INPUT, Oracle will complain.
All of the parameters are optional just like in regular HTML. All parameters are varchars unless otherwise indicated.
procedure sp_html_input
(
@TYPE varchar(30) = NULL -- Input type.
, @NAME varchar(92) = NULL -- Name of item.
, @VALUE varchar(255) = NULL -- Value of item.
, @ALERT varchar(255) = NULL -- JavaScript onClick (alert).
, @CONFIRM varchar(255) = NULL -- JavaScript onClick (confirm).
, @onBlur varchar(255) = NULL -- JavaScript onBlur event handler.
, @onClick varchar(255) = NULL -- JavaScript onClick event handler.
, @onChange varchar(255) = NULL -- JavaScript onChange event handler.
, @onFocus varchar(255) = NULL -- JavaScript onFocus event handler.
, @onSelect varchar(255) = NULL -- JavaScript onSelect event handler.
, @SIZE varchar(4) = NULL -- Size of field.
, @MAXLENGTH varchar(3) = NULL -- MaxLength of field.
, @CHECKED varchar(255) = NULL -- CHECKED if @CHECKED = @VALUE
, @minValue varchar(128) = NULL -- Minimum value allowed.
, @maxValue varchar(128) = NULL -- Maximum value allowed.
, @ROWS varchar(6) = NULL -- ROWS (textarea).
, @COLS varchar(6) = NULL -- COLS (textarea).
, @WRAP varchar(9) = NULL -- WRAP (textarea).
, @DELIMETER char(1) = "," -- Delimeter character.
, @STYLE varchar(3) = "107" -- DATETIME style.
, @ALIGN varchar(5) = NULL -- Input field is right-aligned?
, @SCALE varchar(4) = NULL -- Scale.
, @COMMA varchar(5) = NULL -- Commas are inserted?
, @DEBUG varchar(5) = "FALSE" -- You looking at me?
, @PROCNAME varchar(92) = NULL -- syscomments.
, @BUTTON varchar(30) = NULL -- name in syscomments to search for.
, @DISABLED varchar(6) = "FALSE" -- TRUE / FALSE
, @READONLY varchar(6) = "FALSE" -- TRUE / FALSE
, @tabindex varchar(4) = NULL -- TabIndex
, @NULLVALUE varchar(30) = NULL -- Force NULL option
, @PROLOGUE varchar(255) = NULL
, @EPILOGUE varchar(255) = NULL
, @MULTIPLE varchar(6) = "FALSE" -- TRUE / FALSE
, @SORTED varchar(6) = "TRUE" -- TRUE / FALSE
, @alt varchar(255) = NULL -- {CDATA}
, @accessKey char(1) = NULL -- {CHARACTER}
, @accept varchar(255) = NULL -- {CONTENTTYPES}
--
-- coreattrs
--
, @id varchar(255) = NULL -- {ID}
, @class varchar(255) = NULL -- {CDATA}
, @decoration varchar(255) = NULL -- {STYLESHEET}
, @title varchar(255) = NULL -- {TEXT}
--
-- il8n
--
, @lang varchar(255) = NULL -- {LANGUAGECODE}
, @dir varchar(255) = NULL -- {ltr|rtl}
--
-- events
--
, @onDblClick varchar(255) = NULL -- {SCRIPT}
, @onMouseDown varchar(255) = NULL -- {SCRIPT}
, @onMouseUp varchar(255) = NULL -- {SCRIPT}
, @onMouseOver varchar(255) = NULL -- {SCRIPT}
, @onMouseMove varchar(255) = NULL -- {SCRIPT}
, @onMouseOut varchar(255) = NULL -- {SCRIPT}
, @onKeyPress varchar(255) = NULL -- {SCRIPT}
, @onKeyDown varchar(255) = NULL -- {SCRIPT}
, @onKeyUp varchar(255) = NULL -- {SCRIPT}
)
| Parameter | Description |
|---|---|
type |
TYPE is the type of input field you want to build. You can pass all of the standard HTML types (including SELECT and TEXTAREA). In addition, there are predefined types which correspond to similarly named datatypes in Sybase and Oracle. A description of each is documented below. |
name |
NAME is the name of this field. Remember that a recent change to Sybernet
no longer requires that parameter names to Sybase stored procedures require
the preceding at-sign.
NAME may also be the name of a column in a Sybase table. In this case TYPE, SIZE and MAXLENGTH are automatically determined. A fully qualified name may also include the name of the database and owner; for example, PDS.DBO.EMPPER.EMP_ID represents the column EMP_ID in table EMPPER owned by DBO in the database PDS; however, for efficieny sake, do not include the database name if you are already in that database. |
value |
VALUE is the default value of this field.
For numeric data, your VALUE parameter may contain gratutious commas. They will be stripped and reedited when your field is built. If you are creating a drop-down list (type=select), the value can be a simple list of names separated by a delimiter (a,b,c,d), a list of name=value pairs (1=a,2=b,3=c,4=d) in which case both the value and text are specified, or a SQL select statement which is evaluated in real-time. |
alert |
ALERT calls the JavaScript function alert. The effect is an alert box with the message in this parameter, and the form is not submitted. |
confirm |
CONFIRM calls the JavaScript function confirm. This causes a warning or confirmation to be displayed that allows the user to cancel or allow the submit; for example, you may wish to warn them that a particular button is going to delete a record. |
onblur |
A blur event occurs when a select, text, or textarea field on a form loses focus. The onBlur event handler executes JavaScript code when a blur event occurs. |
onclick |
onClick handles the onClick event handler. In this case you must
supply the complete JavaScript syntax yourself, and that is its purpose.
onClick may be specified for buttons, radio buttons, checkboxes, submit buttons and reset buttons. ALERT, CONFIRM and onClick are invoked in this order. ALERT will override CONFIRM and onClick. CONFIRM will override onClick if its result is FALSE. |
onchange |
A change event occurs when a select, text, or textarea field loses focus
and its value has been modified. The onChange event handler executes
JavaScript code when a change event occurs.
The onChange event is where the SDK validates input fields. If specified, your onChange code occurs before any validation by the SDK. |
onfocus |
A focus event occurs when a field receives input focus by tabbing with the keyboard or clicking with the mouse. Selecting within a field results in a select event, not a focus event. The onFocus event handler executes JavaScript code when a focus event occurs. |
onselect |
A select event occurs when a user selects some of the text within a text or textarea field. The onSelect event handler executes JavaScript code when a select event occurs. |
tagsize |
TAGSIZE is the size of this input field. If TAGSIZE is not specified and TYPE is a Sybase datatype, TAGSIZE is determined by that datatype; for example, the TAGSIZE of TINYINT will be 3 since the range of valid values are whole numbers between 0 and 255. |
maxlength |
MAXLENGTH is the maximum number of characters that may be specified in this
field. If not specified, the default is 255.
If MAXLENGTH is not specified and TYPE is a Sybase datatype, MAXLENGTH is determined by that datatype; for example, the MAXLENGTH of a TINYINT field will be 3 since the range of valid values are whole numbers between 0 and 255 . |
checked |
CHECKED applies only to types of RADIO, CHECKBOX and SELECT. Its value is compared to
the value of the VALUE parameter and sets the CHECKED (or SELECTED) option when the two are
equal.
To set CHECKED manually, simply pass the same value for CHECKED and VALUE. |
minvalue |
If TYPE is a Sybase numeric field, minValue determines the minimum value
allowed in this field. If minValue is not specified, the minimum value
for that datatype is used instead; for example, the smallest value for a
TINYINT is 0.
minValue is a string and can also be used to specify the minimum value allowed for char, varchar, datetime, and smalldatetime fields. In this case it is a good idea to provide a default value. |
maxvalue |
If TYPE is a Sybase numerc field, maxValue determines the maximum value
allowed in this field. If maxValue is not specified, the maximum value
for that datatype is used instead; for example, the largest value for a
TINYINT is 255.
maxValue is a string and can also be used to specify the maximum value allowed for char, varchar, datetime, and smalldatetime fields. |
rows |
ROWS applies only to TYPE=TEXTAREA and indicates the number of rows to be displayed. |
cols |
COLS applies only to TYPE=TEXTAREA and indicates the number of columns to be displayed. |
wrap |
WRAP applies only to TYPE=TEXTAREA and indicates how text is wrapped when it is displayed and edited. NOWARP means no wrapping occurs. VIRTUAL means text wraps automatically to fit the textarea's window. PHYSICAL is similar to VIRTUAL except that carriage returns are physically inserted in the text at the end of each line. |
delimeter |
This parameter allows you to specify the delimeter used to separate list items when creating a drop-down list. |
style |
STYLE allows you to control the format for datetime and smalldatetime
types and corresponds to the same in Sybase. Since date validations
are done by JavaScript, some styles recognized by Sybase may not be
recognized in JavaScript.
In Sybase, the STYLE 8 and 108 correspond to the time relative to January 1, 1900. In the SDK, STYLE 8 and 108 correspond to the time relative to January 1, 2000. |
align |
ALIGN determines whether or not you want to right-align numeric data
when it is edited. Numeric data is any TYPE of TINYINT, SMALLINT, INT,
NUMERIC, and DECIMAL. The SDK will also right-align any non-null
VALUE when ALIGN is TRUE.
ALIGN may be either TRUE, FALSE, or NULL. When NULL, the default is FALSE unless the TYPE is MONEY or SMALLMONEY. MONEY and SMALLMONEY default to TRUE (right-alignment) when ALIGN is NULL. |
scale |
For numeric data, SCALE determines the number of decimal digits that are displayed. When NULL, SCALE will automatically default to the number of decimal digits that were entered by the user or 2 when the TYPE is one of MONEY or SMALLMONEY. |
comma |
This option determines whether or not numeric data is suppose to
contain commas at the expected position. When TRUE, 1234 is displayed
as 1,234. Since numeric fields containing commas are not valid
Sybabase values, you will have to manually remove them before they
are converted to a numeric data type.
If TYPE is one of MONEY or SMALLMONEY, the default is TRUE. For all other numeric types, the default is FALSE. |
debug |
For Internal Use Only. |
procname |
If TYPE is CHOOSE, this parameter determines the procedure name that should be scanned. |
button |
If TYPE is CHOOSE, this parameter determines the token name that should be scanned. |
The following types are recognized by SP_HTML_INPUT. These types include the standard HTML input types as well as predefined types that correspond to similarly named datatypes in Sybase and Oracle.
The predefined types can include a default tag size, maxlength, value, minValue, maxValue, and scaling. You have the ability to override any or all of these defaults. A BIT type, for example, may be specified with a maxValue of 3.
| Type | Description |
|---|---|
text |
This is a standard TEXT field. There is no validation unless you provide your own validation with onChange. |
button |
This is a standard BUTTON object. |
checkbox |
This is a standard CHECKBOX object. |
radio |
This is a standard RADIO object. |
reset |
This is a standard RESET button. |
submit |
This is a standard SUBMIT button. |
password |
This is a standard PASSWORD field. |
file |
This is a standard FILE object. To use you must set ENCTYPE to "multipart/form-data." |
hidden |
This is a standard HIDDEN field. |
select |
This type creates a select list using the standard <SELECT> and </SELECT> tags.
The VALUE parameter determines the list items.
The CHECKED parameter determines which item is selected.
By default list items are separated by a comma and the text part is sorted before it is displayed.
The VALUE parameter may be a simple list of names:
VALUE = 'Red,Green,Blue'
which returns Red, Green, or Blue to your program. You can also define not only the TEXT portion of each option, but also the VALUE part. To do this you need to precede each item with its value followed by an equal sign.
VALUE = '1=Red,2=Green,3=Blue'
which returns 1, 2, or 3 to your program. If NULL is an option, this can be accomplished by including a null item in your list.
VALUE = ',Red,Green,Blue'
List items can also be derived in real-time by selecting them from a table:
VALUE = 'SELECT NAME FROM HTTP.COLORS'
To specify both the VALUE and TEXT you simply select two columns:
VALUE = 'SELECT VALUE, NAME FROM HTTP.COLORS'
but remember that the TEXT part is automatically sorted. You can suppress this if your select statement includes an ORDER BY clause:
VALUE = 'SELECT VALUE, NAME FROM HTTP.COLORS ORDER BY VALUE'
although in this example it is more natural to order by NAME instead of by VALUE. When given the choice, I would always specify my own ORDER BY clause because Oracle can sort these items faster than I can. |
textarea |
This type creates a textarea using the standard <TEXTAREA> and </TEXTAREA> tags.
The VALUE parameter determines the value of your textarea.
Like SELECT above VALUE may be a select statement. Only one column from a single row may be selected, but almost any column type is allowed, including a CLOB. If you attempt to retrieve a row greater than MAXLENGTH, an error is raised. An error is also raised if you attempt to retrieve more than one row. NULL is returned if no rows were found. Here is an example that creates a textarea:
exec http.dbo.sp_html_input
(
@TYPE = 'TEXTAREA'
, @VALUE = 'Please fill this in'
, @ROWS = '20'
, @COLS = '60'
) ;
Here is an example that retrieves a CLOB:
exec http.dbo.sp_html_input
(
@TYPE = 'TEXTAREA'
, @VALUE = 'SELECT DESCRIPTION FROM HTTP.HTTP_HELPTEXT WHERE ROW_ID = ''Welcome'''
, @ROWS = '20'
, @COLS = '60'
, @MAXLENGTH = '32767'
) ;
MAXLENGTH should not be greater than 32767. |
alpha |
This special type allows letters only. |
bit |
This Sybase datatype is validated to insure that it is numeric and falls within the range of values supported by this type; for example, TINYINT must be an integral value between 0 and 255. Commas are also removed when the field is validated unless COMMAS=TRUE. |
char |
A character field and the same as text. |
date |
By default, date fields are converted to the form Month day, year; for example,
Dec 25, 1995. The current implementation uses built-in
JavaScript functions which automatically correct for invalid dates; for example,
a date of "12/32/1996" is converted to "Jan 1, 1997." You can control the
style of date formats with the STYLE parameter.
|
datetime |
By default, date fields are converted to the form Month day, year; for example,
Dec 25, 1995. The current implementation uses built-in
JavaScript functions which automatically correct for invalid dates; for example,
a date of "12/32/1996" is converted to "Jan 1, 1997." You can control the
style of date formats with the STYLE parameter.
|
decimal |
A numeric value. |
int |
This Sybase datatype is validated to insure that it is numeric and falls within the range of values supported by this type; for example, TINYINT must be an integral value between 0 and 255. Commas are also removed when the field is validated unless COMMAS=TRUE. |
money |
A comma-separated numeric field. |
number |
A numeric value. |
numeric |
A numeric value. |
phone |
This type removes non-numeric data when an onChange event occurs. This allows the user to enter these values in any format while at the same time making sure that only numeric data is returned to your procedure. |
smalldatetime |
By default, date fields are converted to the form Month day, year; for example,
Dec 25, 1995. The current implementation uses built-in
JavaScript functions which automatically correct for invalid dates; for example,
a date of "12/32/1996" is converted to "Jan 1, 1997." You can control the
style of date formats with the STYLE parameter.
|
smallint |
This Sybase datatype is validated to insure that it is numeric and falls within the range of values supported by this type; for example, TINYINT must be an integral value between 0 and 255. Commas are also removed when the field is validated unless COMMAS=TRUE. |
smallmoney |
A comma-separated numeric value. |
ssn |
This type removes non-numeric data when an onChange event occurs. This allows the user to enter these values in any format while at the same time making sure that only numeric data is returned to your procedure. |
telephone |
A telephone number. |
time |
The TIME datatype converts time to a 24 hour clock value; for example, 2:15 pm is converted to 1415. |
tinyint |
This Sybase datatype is validated to insure that it is numeric and falls within the range of values supported by this type; for example, TINYINT must be an integral value between 0 and 255. Commas are also removed when the field is validated unless COMMAS=TRUE. |
varvhar |
A text field. |
varchar2 |
A text field. |
The following table summarizes the default tag sizes and the min and max values. When calling SP_HTML_INPUT, you have the ability to override any of these values.
| TYPE | TAGSIZE | MAXLENGTH | MINVALUE | MAXVALUE |
|---|---|---|---|---|
| ALPHA | 30 | 255 | null | null |
| BIT | 1 | 1 | 0 | 1 |
| BLOB | 30 | 32767 | null | null |
| BUTTON | null | null | null | null |
| CHAR | 20 | 255 | null | null |
| CHECKBOX | null | null | null | null |
| CHOOSE | 1 | null | null | null |
| CLOB | 30 | 32767 | null | null |
| DATE | 12 | 26 | null | null |
| DATETIME | 12 | 26 | null | null |
| DECIMAL | 20 | null | null | null |
| FILE | null | null | null | null |
| HIDDEN | null | null | null | null |
| INPUT | 20 | null | null | null |
| INT | 14 | 14 | -2147483648 | 2147483647 |
| INTEGER | 14 | 14 | -2147483648 | 2147483647 |
| MONEY | 12 | 25 | -922337203685477.5808 | 922337203685477.5807 |
| NUMBER | 20 | null | null | null |
| NUMERIC | 20 | null | null | null |
| PASSWORD | 30 | 30 | null | null |
| PHONE | 13 | 13 | null | null |
| RADIO | null | null | null | null |
| RESET | null | null | null | null |
| SELECT | 1 | null | null | null |
| SMALLDATETIME | 12 | 26 | null | null |
| SMALLINT | 7 | 7 | -32768 | 32767 |
| SMALLMONEY | 12 | 13 | -214748.3648 | 214748.3647 |
| SSN | 11 | 11 | null | null |
| SUBMIT | null | null | null | null |
| TELEPHONE | 24 | 24 | null | null |
| TEXT | 20 | null | null | null |
| TEXTAREA | null | 255 | null | null |
| TIME | 8 | 8 | null | null |
| TINYINT | 3 | 3 | 0 | 255 |
| VARCHAR | 20 | 255 | null | null |
| VARCHAR2 | 20 | 255 | null | null |
DATE, DATETIME, and SMALLDATETIME are essentially the same data type. The table above illustrates each for style 107. The remaining styles are defined here.
| STYLE | TAGSIZE | MAXLENGTH | FORMAT |
|---|---|---|---|
| 0 | 19 | 26 | Mon DD YYYY HH12:MIAM |
| 1 | 8 | 26 | MM/DD/YY |
| 2 | 8 | 26 | YY.MM.DD |
| 3 | 8 | 26 | DD/MM/YY |
| 4 | 8 | 26 | DD.MM.YY |
| 5 | 8 | 26 | DD-MM-YY |
| 6 | 9 | 26 | DD Mon YY |
| 7 | 10 | 26 | Mon DD, YY |
| 8 | 8 | 26 | HH24:MM:SS |
| 9 | 26 | 26 | Mon DD YYYY HH12:MI:SS AM |
| 10 | 8 | 26 | MM-DD-YY |
| 11 | 8 | 26 | YY/MM/DD |
| 12 | 6 | 26 | YYMMDD |
| 13 | 8 | 26 | YY/DD/MM |
| 14 | 8 | 26 | MM/YY/DD |
| 15 | 8 | 26 | DD/YY/MM |
| 100 | 19 | 26 | Mon DD YYYY HH12:MIAM |
| 101 | 10 | 26 | MM/DD/YYYY |
| 102 | 10 | 26 | YYYY.MM.DD |
| 103 | 10 | 26 | DD/MM/YYYY |
| 104 | 10 | 26 | DD.MM.YYYY |
| 105 | 10 | 26 | DD-MM-YYYY |
| 106 | 11 | 26 | DD Mon YYYY |
| 107 | 12 | 26 | Mon DD, YYYY |
| 108 | 8 | 26 | HH24:MM:SS |
| 109 | 26 | 26 | Mon DD YYYY HH12:MI:SS AM |
| 110 | 10 | 26 | MM-DD-YYYY |
| 111 | 10 | 26 | YYYY/MM/DD |
| 112 | 8 | 26 | YYYYMMDD |
| 113 | 10 | 26 | YYYY/DD/MM |
| 114 | 10 | 26 | MM/YYYY/DD |
| 115 | 10 | 26 | DD/YYYY/MM |
You may be asking yourself if you can create your own primitive datatypes. The answer is yes because all of these types are stored in the table called HTTP.HTTP_DATATYPES. Here is an example that defines a new type called COLOR. It creates a drop-down list of all colors from the table HTTP.HTTP_COLORS.
Don't be misled into thinking that you must add your own types to use this procedure. On the contrary, unless you expect the above type (COLOR) to be used in several places, I would advise that you do not create such a type.
The first example is a simple input field. There are two things to note about this example: the procedure will automtically quote the ADDRESS value for you, and this value will not be concatenated to any other string because that might result in truncation.
exec http.dbo.sp_html_input
@TYPE = 'text'
, @NAME = 'address'
, @VALUE = ADDRESS
, @SIZE = '30'
Here are two radio buttons. sp_html_input will automatically determine if the button is checked based on the parameter name (PIZZA). This is actually very convenient because to do this yourself you would have to test whether or not PIZZA was equal to each button value.
exec http.dbo.sp_html_input
@TYPE = 'radio'
, @NAME = 'PIZZA'
, @VALUE = 'Cheese'
, @CHECKED = @PIZZA
exec http.dbo.sp_html_input
@TYPE = 'radio'
, @NAME = 'PIZZA'
, @VALUE = 'Pepperoni'
, @CHECKED = @PIZZA
The next example illustrates how you can use Sybase datatypes when calling sp_html_input.
exec http.dbo.sp_html_input
@TYPE = 'SMALLINT'
, @NAME = 'Balance'
Because they were not specified, the Sybernet SDK will automatically set both SIZE and MAXLENGTH to 6. It will also validate that the value in this field is a whole number between -32,768 and 32,767. Here's another example that overrides these defaults:
exec http.dbo.sp_html_input
@TYPE = 'INT'
, @NAME = 'Account'
, @SIZE = '30'
, MAXLENGTH = '30'
, @minValue = '200000'
, @maxValue = '299999'
The next example specifies the Sybase datetype DATETIME and validates that the date entered is at least November 25, 1996.
exec http.dbo.sp_html_input
@TYPE = 'DATETIME'
, @NAME = 'Birthday'
, @minValue = 'Nov 25, 1996'
A standard submit button which displays a confirmation before submitting the form. The button is named because the procedure that receives this form wants to know which button the user clicked.
exec http.dbo.sp_html_input
@TYPE = 'submit'
, @NAME = 'button'
, @VALUE = 'Save'
, @CONFIRM = 'Are you sure you want to save this form?'
Similar to the example above except an alert is displayed and the form is not submitted. Normally, this would be preceded by some condition that tests whether or not the user is allowed to click this button.
exec http.dbo.sp_html_input
@TYPE = 'submit'
, @NAME = 'button'
, @VALUE = 'Drop'
, @ALERT = 'You are not permitted to drop this form!'
This is just a simple button that behaves exactly like the BACK button on your browser's tool bar. Notice that it uses the onClick event handler and supplies the entire JavaScript code in the onClick parameter.
exec http.dbo.sp_html_input
@TYPE = 'button'
, @VALUE = 'Back'
, @onClick = 'window.history.back()'
Version 2.22 of the Sybernet SDK introduced 3 new parameters that allow you to control how numeric data is displayed and edited by the user. They are ALIGN, SCALE and COMMA.
ALIGN may be either TRUE, FALSE or NULL. When TRUE, numeric data is right-aligned.
SCALE is a positive integer that determines the number of decimal digits that are displayed and edited. If zero, no decimal digits are displayed.
COMMAS may be either TRUE, FALSE or NULL. When TRUE, commas are inserted at the expected location.
exec http.dbo.sp_html_input
@TYPE = 'NUMERIC'
, @VALUE = '1,234.5678'
, @ALIGN = 'TRUE'
, @SCALE = '2'
, @COMMAS = 'TRUE'
In the above example, the value is right-aligned, scaled to two decimal
digits, and commas are inserted at the proper position. Notice too that
the value contains commas; these are removed and then reinserted as
expected.
The following example illutrates how to create a drop-down list. The value part is simply a list of names separated by commas. The list is sorted automatically:
exec http.dbo.sp_html_input
@TYPE = 'SELECT'
, @NAME = 'FOOD'
, @VALUE = 'Apples,Oranges,Pears,Turnips,Grapefruit,Watermelon,Pizza,Chicken'
The same example except that I want to specify both the value and text values. To do this I simply pass these as pairs separated by an equal sign. The list is sorted by the text value in this case:
exec http.dbo.sp_html_input
@TYPE = 'SELECT'
, @NAME = 'FOOD'
, @VALUE = '1=Apples,2=Oranges,3=Pears,4=Turnips,5=Grapefruit,6=Watermelon,7=Pizza,8=Chicken'
The following example illustrates how to create a list dynamically using a table:
exec http.dbo.sp_html_input
@TYPE = 'SELECT'
, @NAME = 'PLATFORM'
, @VALUE = 'SELECT PLATFORM FROM CRON_PLATFORMS'
The following example illustrates how to select both value and text from a table. Because an order by clause was specified, the list is not sorted:
exec http.dbo.sp_html_input
@TYPE = 'SELECT'
, @NAME = 'DATENAMES'
, @VALUE = 'select selectedIndex, datename from cron_datenames order by selectedIndex'