Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display cfselect selected values on update page

Status
Not open for further replies.

mdmatt

Technical User
Dec 17, 2007
19
US
I am trying to create an update page for an application for road assessments. I am using cfsliders and cfselect to display the raw numbers of an assessment for in the field editing purposes. My sliders work as they should, but I can not seem to get the selected value to work in the cfselect; it diplays the first value in the control table, not the value from the data table. I am using a query for the display and value of the select (rsAlligator) and a separate query for the actual assessment data (rsRATINGRAW).
------------------SHORT VERSIONS QUERIES----
<cfquery name="rsRATINGRAW" datasource="Pave">
SELECT RID, SEVERITY, EXTENT, TRANSVERSE
FROM dbo.EDITRATINGvw
WHERE dbo.EDITRATINGvw.RID=
<cfqueryparam value="#FORM.RID#">
</cfquery>

<cfquery name="rsALLIGATOR" datasource="Pave">
SELECT CLASS, EXTENT, SEVERITY
FROM dbo.PAVEMENTMGMTASPHALTALLIGATOR
</cfquery>

--------------------short FORM-----

<cfform action="EDITRATING.cfm" method="post" name="update" >

<table width="600" border="3" cellspacing="1" cellpadding="1">


<tr>
<td>ALLIGATOR SEVERITY</td>
<td><cfselect
name="SEVERITY"
query="rsALLIGATOR"
value="SEVERITY"
display="CLASS"
queryPosition="below"
width="250"
selected="#rsRATINGRAW.SEVERITY#"
></cfselect></td></tr>

<tr>
<td>ALLIGATOR EXTENT</td>
<td><cfselect
name="EXTENT"
query="rsALLIGATOR"
value="EXTENT"
display="CLASS"
queryPosition="below"
width="250"
selected="#rsRATINGRAW.EXTENT#" ></cfselect>
</td></tr>
<tr>
<td>TRANSVERSE</td>
<td><cfslider name="TRANSVERSE" range="0,3" bgcolor="orange" scale="1" width="300" height="40" lookandfeel="METAL" font="Arial, Helvetica, sans-serif" fontsize="16" bold="NO" align="MIDDLE" label="__ __ " value="#rsRATINGRAW.TRANSVERSE#"></td> </tr>
</table></cfform>
------------------------
I initially tried to use the radio button form that I used for the insert record page, but I do not know how I populate the value of the radio buttons on the update page. Either way, I would appreciate any knowledge or suggestions that you can offer.
Thanks - Matt
 
Start by checking the simple things.

1. Verify the code is passing in the correct "selected" value. Cfdump the rsRATINGRAW query. Does it contain more than one record? If so, this syntax will only pass in the first record:

selected="#rsRATINGRAW.SEVERITY#"

2. Verify the selected "value" actually matches one of the "values" in your cfselect list

----------------------------------
 
cfsearching,
Thanks for the great suggestions, I did the cfdump and there was one record with the correct numbers in the fields.
I then double checked my database tables, I did find an error, but it did not fix my problem.
I changed the cfselect display to = the value as well SEVERITY AND EXTENT and reran it, the dump shows the numbers (2 and 5) but the select displayed 0.
Here is what I have, (I had to add a field - SURFDESC because of a cfif statement)
----queries---
<cfquery name="rsRATINGRAW" datasource="Pave">
SELECT RID, SEVERITY, EXTENT, TRANSVERSE, SURFDESC
FROM dbo.EDITRATINGvw
WHERE dbo.EDITRATINGvw.RID='1073'

</cfquery>
<cfquery name="rsALLIGATOR" datasource="Pave">
SELECT CLASS, EXTENT, SEVERITY
FROM dbo.PAVEMENTMGMTASPHALTALLIGATOR
</cfquery>

<cfdump var="#rsRATINGRAW#">
----form----
<cfform action="EDITRATING.cfm" method="post" name="update" >

<table width="600" border="3" cellspacing="1" cellpadding="1">


<tr>
<td>ALLIGATOR SEVERITY</td>
<td><cfselect
name="SEVERITY"
query="rsALLIGATOR"
value="SEVERITY"
display="SEVERITY"
queryPosition="below"
width="250"
selected="#rsRATINGRAW.SEVERITY#"
></cfselect>


</td>
</tr>
<tr>
<td>ALLIGATOR EXTENT</td>
<td><cfselect
name="EXTENT"
query="rsALLIGATOR"
value="EXTENT"
display="EXTENT"
queryPosition="below"
width="250"
selected="#rsRATINGRAW.EXTENT#" ></cfselect>

</td>
</tr>
<tr>
<td>TRANSVERSE</td>
<td><cfslider name="TRANSVERSE" range="0,3" bgcolor="orange" scale="1" width="300" height="40" lookandfeel="METAL" font="Arial, Helvetica, sans-serif" fontsize="16" bold="NO" align="MIDDLE" label="__ __ " value="#rsRATINGRAW.TRANSVERSE#"></td> </tr>
</table></cfform>

Thanks again,
Matt
 
I am not sure I follow. Shows 'shows the numbers (2 and 5)' where?

1. Dump the query used for the cfselect ie "rsALLIGATOR". what are the values in the "SEVERITY" column?

2. Dump the #rsRATINGRAW# query. What is the value of #rsRATINGRAW.SEVERITY# ?

#rsRATINGRAW.SEVERITY# has to match one of the values in the first query (including spaces if applicable). Otherwise, the first list element will always be selected.

Example:
#rsRATINGRAW.Severity# row 1 value equals "82" AND
#rsALLIGATOR.Severity# contain values: 1,2,3,4,5

Nothing will be selected.

----------------------------------
 
I'm sorry, the dump table displayed the correct values, while the form did not.
I will try your suggestions and let you know what the results are tomorrow.
Thanks again - Matt
 
I have been testing in Mozilla, I tried it in IE7 and it worked. So my code and tables were right(after double checking and fixing a simple table error), but the problem must lie in the browser. Thank you for all your help. Any thoughts on why cfselect is not working in Firefox?
Thanks again - Matt
 
Cfselect simply generates a regular html <select ..> in the background. As it is a pretty basic element that has been around forever, it seems unlikely there is a browser issue.

I really could not say more without seeing the actual data dumps, or the generated html for the list you say is not working.

----------------------------------
 
The table error must have been stuck in the Firefox cache, I cleared it and it didn't work, so I re-cleared the cache then rebooted the pc and re-cleared the cache again, reran the test page and it worked fine. Thanks again for all of your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top