Hiya,

You can also write the following, depending on whether you are trying to
get the page into structural XHTML (changes from the example below are
highlighted in bold):

<select name="fieldname">
    <option value="" selected="selected">-- Select a Company ---</option>
    <cfoutput query="queryname">
        <option value="#recordvalue#"> #recordvalue#</option>
    </cfoutput>
</select>

Just writing selected will also work, but it is good practice to keep all attributes in the same format :)

Kind regards
Natalie

Natalie Downe - Systems Analyst
Zone 2 Solution Center
Lilly Deutschland GmbH, Teichweg 3, 35396 Giessen, Germany
Tel: +49 641 9533 1725, Fax: +49 641 9533 1609
E-Mail: [EMAIL PROTECTED], Internet: www.lilly.com




"Adam St. Pierre" <[EMAIL PROTECTED]>
24/03/2004 14:25
Please respond to cf-newbie

        To:     CF-Newbie <[EMAIL PROTECTED]>
        cc:
        Subject:        RE: cfselect :: default selected item shows up last

Try doing this:

<select name="fieldname">
    <option value="" selected>-- Select a Company ---
    <cfoutput query="queryname">
        <option value="#recordvalue#"> #recordvalue#
    </cfoutput>
</select>

This is the non-cfselect option. I think it has to do with the query
your using to pull values out of the database. If your query displays
the options with the value "selected" on every one, it's going to go
right to the bottom.

Also, as far as I know, it should just be "selected", not
selected="true".

The only time you really need to use CF form fields is when you want
built in client-side error checks. Since you're puling the values from a
database, they should all be valid, in general.

Hope it helps!
- Adam

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 23, 2004 4:03 PM
To: CF-Newbie
Subject: cfselect :: default selected item shows up last

I'm using cfselect to create a pull-down list from a query, of all the
company names in a database.

I'd like the default to be an option with a null value, with the label "
--SELECT A COMPANY--".

I did this by sticking this inside my CFSELECT <option value="" selected
="true">--Select a Company--</option>

It works fine, but when you click on the form object and the list opens,
this option is listed last, I'd like it to appear up top, is there a way
to
force this?

Paul Colombo
Multimedia Programmer
webLearning.com
w: 973.227.4455
c:  201.819.9027
f:  973.227.8412
________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to