Re: cf select

by "Paul Varese" <varese(at)home.com>

 Date:  Thu, 3 Aug 2000 23:17:10 -0700
 To:  "Steve Ball" <sball99(at)mindspring.com>
 Cc:  "'HTML Writer's Guild - Languages'" <hwg-languages(at)hwg.org>
 References:  spb01
  todo: View Thread, Original
Although I've only used Cold Fusion a little bit, I use ASP a lot to do
this. I'll show you how I usually do it in ASP and I'm sure you can figure
out the CFML

Assuming that you have a variable called strState containing the name of a
state, and a recordset called rsState containing the list of states;

<select name="State">

<option value="">Select a State

<%

    Do While Not rsState.EOF

    If strState = rsState("StateName") Then

%>

    <option value="<%=rsState("StateName")%>"
SELECTED><%=rsState("StateName")%>

<% Else %>

    <option value="<%=rsState("StateName")%>"><%=rsState("StateName")%>

<% End If

    rsState.MoveNext

    Loop

%>

</select>


If you get really stuck, I can show you the CFML, but I might need to look
at a book to get it just right.

C-ya - Paul R.S.V.




----- Original Message -----
From: "Steve Ball" <sball99(at)mindspring.com>
To: <hwg-languages(at)hwg.org>
Sent: Thursday, August 03, 2000 8:41 AM
Subject: RE: cf select


> List,
>
> I am trying to display a list (of locations) in a select drop-down,
> "highlighting" (and defaulting to) the location choice which is the result
> of one unique row of a query.  That data element has been previously
chosen
> from a similar dropdown.  My current solution is to simply display the
> current value to the user, and provide another select dropdown enabling
the
> user to change the current choice.  Thus I am using two queries.  Somewhat
> inelegant.  I am doing this in ColdFusion, but the fundamental technology
is
> html select.  Any suggestions?
>
> Thanks!
>
> Here is the current script as described:
>
****************************************************************************
> ************************************************
> </CFFORM>
>
> <!---
> CHANGE YOUR LOCATION FORM --->
>
>     <tr>
>     <TD colspan=2> Your Location:  #editprofile.location#<br><br>
> If you wish to change your location, please choose from the list below,
and
> click "Submit" to update your information.</TD>
>  </tr>
>   <tr>
> <td colspan=2>
> <cfform name=locationform action="profile_update2.cfm">
> <cfquery name="qlocation" datasource="learn_res">
> SELECT location.location, location.locationid
> FROM location
> ORDER BY location
> </cfquery>
>
> <CFSELECT NAME="lselect"
> size=5
> query="qlocation"
> value="locationid"
> display="location"
> required="yes"
> message="Please select your location and press Submit to continue">
> <option>#location#
> </CFSELECT>
>
> </td>
> </tr>
>
> <tr><td colspan=2><script
> src="../js/simple-submit.js"></script></td></td></tr>
> <tr><td colspan=2><hr></td></tr>
> </CFFORM>
> </table>
>
>
****************************************************************************
> **********************************************
> Note that the data element "editprofile.location" is based on a select
> query, "editprofile", returning a unique row with value for location,
while
> the select list is based on a separate query, "qlocation".  I'm trying to
> figure out some way to pass the editprofile.location value to the select
> function to id the current value.
>
****************************************************************************
> **********************************************
>
> > -----Original Message-----
> > From: Peter Benoit [mailto:pbenoit(at)triton-network.com]
> > Sent: Tuesday, August 01, 2000 8:35 AM
> > To: 'Steve Ball'
> > Subject: RE: cf select
> >
> >
> > Ok, I read it 3 times and still dunno what yer trying to do.  You have
the
> > cf example somewhere?
> >
> > -----Original Message-----
> > From: Steve Ball [mailto:sball99(at)mindspring.com]
> > Sent: Sunday, July 30, 2000 2:16 PM
> > To: hwg-languages(at)hwg.org
> > Subject: cf select
> >
> >
> > Hi list,
> >
> > Anyone know how to set up a query based dynamic select to
> > initially focus on
> > one row, but allowing the user to update to another?  The specific
script
> > language targeted is ColdFusion (CFSelect), but if there is a
> > generic (html)
> > solution I can adapt.  All I've been able to do is display the existing
> > value in a form and allow an update from a select list based on another
> > query.  Not very elegant...
> >
> > tia
> > Steve Ball
> >
> >
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA