Try this code for the select bit:
<select name="CatergoryHeading">
<cfoutput>
<cfloop from="1" to="#RecordsetGetMenu.recordcount#" index="i">
<option value="#RecordsetGetMenu.LinkCatergory[i]#" <cfif
isdefined("recordset1.CatergoryHeading") AND recordset1.CatergoryHeading eq
RecordsetGetMenu.LinkCatergory[i]>selected</cfif>>selected</cfif>>#Recordset
GetMenu.LinkCatergory#</option>
</cfloop>
</cfoutput>
</select>
This makes sure there is no ambiguity in the variables which I think may be
causing your problems:
Full code with my changes:
-----------------------------------------------
<cfquery name="Recordset1" datasource="hike">
SELECT *
FROM globallinks
WHERE UserName = '<cfoutput>#getauthuser()#</cfoutput>'
</cfquery>
<cfquery name="RecordsetGetMenu" datasource="hike">
SELECT LinkCatergory
FROM dbo.GlobalLinkCatergory
WHERE LinkCatergory IS NOT null
</cfquery>
<cfloop query = "recordset1">
<form method="post" name="form1"
action="">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">CatergoryHeading:</td>
<td>
<select name="CatergoryHeading">
<cfoutput>
<cfloop from="1" to="#RecordsetGetMenu.recordcount#" index="i">
<option value="#RecordsetGetMenu.LinkCatergory[i]#" <cfif
isdefined("recordset1.CatergoryHeading") AND recordset1.CatergoryHeading eq
RecordsetGetMenu.LinkCatergory[i]>selected</cfif>>selected</cfif>>#Recordset
GetMenu.LinkCatergory#</option>
</cfloop>
</cfoutput>
</select>
</td>
<tr><td>This is what the value
should be! <cfoutput>#recordset1.catergoryheading#</cfoutput> </td></tr>
<tr>
</cfloop>
Regards,
Dan.
-----Original Message-----
From: John Munyan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 19, 2003 23:49
To: CF-Talk
Subject: Question about populating pulldown menus with queries (Beginner)
I am creating a page to allow users to edit links they have created.
The links are grouped into categories such as personal hiking sites, or
weather sites, etc. When users are editing their links I want to
display the current value in the database as the currently selected
value in a pull down menu.
The pull down menu category values are in a separate table.
The specific problem I am having (and haven't been able to solve - in an
embarrassing amount of time) is that when looping over the form the
first query results values are populated into all the pull down menus.
Other fields I have which are represented as text don't have this
problem. I am at a loss to explain/figure out what to do to properly
populate the pull down menu with the current version.
Any help would be most appreciated :-)
I have included what I have below in hopes someone might be able to
point me in the right direction - again thanks!
The globallinks table has user specified data that should be editable
(recordset1).
The RecordsetGetMenu query has the categories I am trying to populate to
the pulldown menu.
<!--- The queries --->
<cfquery name="Recordset1" datasource="hike">
select *
from globallinks
where UserName = '<cfoutput>#getauthuser()#</cfoutput>'
</cfquery>
<cfquery name="RecordsetGetMenu" datasource="hike">
SELECT LinkCatergory
FROM dbo.GlobalLinkCatergory where LinkCatergory is not null
</cfquery>
<cfloop query = "recordset1">
<form method="post" name="form1"
action="">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">CatergoryHeading:</td>
<td>
<select name="CatergoryHeading">
<cfoutput query="RecordsetGetMenu">
<option value="#RecordsetGetMenu.LinkCatergory#" <cfif
(isDefined("Recordset1.CatergoryHeading") AND
RecordsetGetMenu.LinkCatergory EQ
Recordset1.CatergoryHeading)>selected</cfif>>#RecordsetGetMenu.LinkCater
gory#</option>
</cfoutput>
</select>
</td>
<tr><td>This is what the value
should be! <cfoutput>#recordset1.catergoryheading#</cfoutput> </td></tr>
<tr>
</cfloop>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]