| home -> documentation -> QRYLIST tag |
Description
This element allows you to create the HTML code needed for the list of a combobox or listbox control based on a dataset. In addition, the element can initially select a specified text or value from the list.
Syntax
| <#QRYLIST FIELDTEXT="AFIELDTEXT" FIELDVALUE="AFIELDVALUE" [SELECTEDTEXT="ASELECTEDTEXT" | SELECTEDVALUE="ASELECTEDVALUE"]>
|
| FIELDTEXT |
This property defines the text values that will be diplayed on the control. The AFIELDTEXT value should be the field name from a dataset.
|
| FIELDVALUE |
This property defines the values linked to the text values displayed on the control. This values are not visible. However, these values are sent when you put form send the information in a post operation. The AFIELDVALUE value should be a field contained in the dataset.
|
| SELECTEDTEXT |
This property defines the item that will be initially selected. It can contain a literal value or an expression. Some item will be selected when his displayed text matches the value stored on this property.
|
| SELECTEDVALUE |
This property defines the dropdownlist item that will be selected. The selected item is that one who FieldValue value is the same as the ASELECTEDVALUE value.
|
Considerations
In order to use the QRYLIST tag it have to be delimited by a DATASET tag. Due to the selectedtext and selectedvalue properties should be dataset's fields is necesary the DATASET declaration.
Applications
The dropdownlist is one of the most common controls that we found in web pages. So, the automation of some html code can help us to save time when we need to work with it.
Examples
Example 1. Setting a default value for the combobox
This example shows you how to select a specific value in a combobox.
Source code
File: examples/qrylistvalue.dbsp
<HTML> <body> <head> <title> Dataset example </title> <link rel="stylesheet" href="http://<#SP_HOST/>/documentation/OperativeExamples/design/dbspdemo.css"> <script language="JavaScript1.2" src="http://<#SP_HOST/>/documentation/OperativeExamples/etc/dbspdemo.js"> </SCRIPT> </head> <form name="forma" method="post" action="QryListExecValue.dbsp?EXAMPLEID=<#EXAMPLEID/>"> <H3><FONT face=Verdana>Selecting a list item (second part)</FONT></H3> <table width="70%"> <tr> <td align="center"> This example shows how select a combobox item using the selectedvalue property. In this page you have to type the value from the list that you want to select. Once you press the submit button a combobox is showed containing the list items showed below. And being the selected item the one who has the value that you have just typed. </td> </tr> </table> <br> <INPUT type="text" name="ctrlVALUE" maxlength="32" size="32"> <input type="submit" name="ctrlSUBMIT" class="boton1" value="submit" action="post"> <br> <br> <TABLE border=1 borderColor=black cellPadding=3 cellSpacing=0 rules=all class="TABLEDATASET"> <td> <tr> <th> Value </th> </tr> <#DATASET ALIAS=DBSPDEMO QUERYID=9> <tr> <td> <#TERRITORYID/> </td> </tr> <#/DATASET> </tr> </td> </table> </form> </body> </html>
|
File: examples/qrylistexecvalue.dbsp
<HTML> <body> <head> <title> Dataset example </title> <link rel="stylesheet" href="http://<#SP_HOST/>/documentation/OperativeExamples/design/dbspdemo.css"> <script language="JavaScript1.2" src="http://<#SP_HOST/>/documentation/OperativeExamples/etc/dbspdemo.js"> </SCRIPT> </head> <form name="forma"> <H3><FONT face=Verdana>Selecting a list item (second part)</FONT></H3> <TABLE border=1 borderColor=black cellPadding=3 cellSpacing=0 rules=all class="TABLEDATASET"> <td> <tr> <td> QueryList </td> <#DATASET ALIAS=DBSPDEMO QUERYID=9> <td> <SELECT name="cbxCOMPANYNAME"> <OPTION value="">Select a code</OPTION> <#QRYLIST FIELDTEXT="TERRITORYID" FIELDVALUE="TERRITORYID" SELECTEDVALUE="ctrlVALUE"/> </SELECT> </td> <#/DATASET> </tr> </td> </table> </form> </body> </html>
|
Test example
|