Introduce a completely different way to make a pull-down menu

Source: Internet
Author: User
Tags key
Menu | Dropdown I was the first time to know this method, never heard before, if I read the content from the database to make the Pull-down menu is to do with the loop, now, let us look at the way of foreigners.

Use recordset.getstring to make dynamic pull-down menus.

Adodb.recordset's GetString method has some bugs, but it can work well for you if you use caution.
First of all, introduce the use of getstring ... As follows:

stringvalue = rsobject.getstring (format, NumRows, ColumnDelimiter, RowDelimiter, Ifnull)

As long as the RS object is established, and the corresponding operation is performed, whether it is to return one or more records, or even a blank record, GetString still works, but if you do not pay attention, this result may not be fun,: P (The foreigner is also humorous enough)

The format parameter has only one legal value, and is optional, let's skip it, if you want to return all the records, then that numrows parameter can also ignore it (optional), ifnull ... As I understand it, like the IsNull function in the TSQL, if it's null, you can replace it with a value, so it doesn't matter.

There are two parameters left .... No more nonsense, first look at their example

<table border=1>
<TR><TD>
<% = Response.Write Rs. GetString (,, "</TD><TD>", "</TD></TR><TR>")%>
</TABLE>
The HTML results of this write are as follows:
<table border=1>
<TR>
<td>row1, Field1 value</td>
<td>row1, Field2 value</td>
</TR>
<TR>
<td>row2, Field1 value</td>
<td>row2, Field2 value</td>
</TR>
<TR>
</TABLE>

This is also a foreigner said that the bug, let us look at the specific how to do

<%
Set RS = conn. Execute ("Select Thevalue,thetext from Selectoptionstable order by TheText")

Optsuffix = "</OPTION>" & vbNewLine
Valprefix = "<option value="
Valsuffix = "' >"
opts = RS. GetString (,, Valsuffix, Optsuffix & Valprefix, "--error--")
' Next ' is the key to it!
opts = Left (opts, Len (opts)-len (Valprefix))

Response.Write "<select ...>" & vbNewLine
Response.Write Valprefix & OPTs
Response.Write "</SELECT>"
%>

Have you ever used this method, to be honest, I've never seen it, and I haven't heard anyone say it:

Incidentally, if you want to create a correct form, that is, the bug I said on the head, just do it:
<%
Set RS = conn. Execute ("SELECT * from table")

Tdsuffix = "</TD>" & vbNewLine & "<TD>
Trprefix = "<TR>" & vbNewLine & "<TD>"
Trsuffix = "</TD>" & vbNewLine & "</TR>" & vbNewLine & "<TR>" & vbNewLine
opts = RS. GetString (,, Tdsuffix, Trsuffix & Trprefix, "--error--")
' Next ' is the key to it!
opts = Left (opts, Len (opts)-len (Trprefix))

Response.Write "<table border=1 cellpadding=5>" & vbNewLine
Response.Write Trprefix & OPTs
Response.Write "</TABLE>" & vbNewLine
%>
------------------------------------------------------------------------
To introduce a completely different approach ... (I saw the faint)

<%
SQL = "Select ' <option value= '", Value, ' > ', Text, ' </OPTION> ' from table order by text
Set RS = conn. Execute (SQL)
Response.Write "<SELECT>" & vbNewLine & RS. GetString (,, "", vbNewLine) & "</SELECT>"
%>

Have you ever used it?

Did you see it? You can return the results directly from the query.
Further, you can do this (I tried it under access)

<%
SQL = "Select ' <option value= '" & Value & ' ' > ' & text & ' </OPTION> ' from table order by text "
Set RS = conn. Execute (SQL)
Response.Write "<SELECT>" & vbNewLine & RS. GetString (,, "", vbNewLine) & "</SELECT>"
%>
........................

:(

I'm not saying much.

I wish I could be of some help to you.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.