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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Now can I get CFSELECT text displayed in the Combobox?

Status
Not open for further replies.

accuransx

Programmer
Sep 23, 2000
62
0
0
MY
I know this seems like silly, maybe some experts can help me on this:

I have 2 CFSELECT boxes.

I'm populating a 2nd CFSELECT from database based on the value (KOD_DAERAH) passed from the first CFSELECT. My code are:

<cfselect name=&quot;cmbKodDaerah&quot; query=&quot;GetDaerah&quot; value=&quot;KOD_DAERAH&quot; selected=&quot;#KOD_DAERAH#&quot; display=&quot;Daerah&quot; onChange=&quot;update_dataN(frmProjek, #ID#);&quot;></cfselect>

<CFSELECT name=&quot;cmbKodMukim&quot; query=&quot;GetMukim&quot; value=&quot;KOD_MUKIM&quot; display=&quot;Mukim&quot; ></CFSELECT>

These are my queries:

<cfquery name=&quot;GetDaerah&quot; datasource=&quot;Keda&quot; dbtype=&quot;ODBC&quot;>
Select * from Kod_Daerah
</cfquery>

<cfquery name=&quot;GetMukim&quot; datasource=&quot;Keda&quot; dbtype=&quot;ODBC&quot;>
Select * from Kod_Mukim where KOD_MUKIM like '#KOD_DAERAH#%'
</cfquery>

My problem is, i still need the area code (KOD_DAERAH) values to populate the 2nd CFSELECT but when it comes to saving data, i want to capture the text showed in the cfselect box, NOT the value. Is there any variable like #form.cmbKodDaerah.text#? I've tried this but failed. Any ideas?
 
No. You can't, as far as I know.

The best you could do is grab the FORM.value (the area code) and either do a query to get the text you want from that row in the database, or create a lookup structure and pull the text that way based on the FORM.value.

Something like:
Code:
<CFSCRIPT>
   myLookupTable = StructNew();
   // you would, of course, create this dynamically
   StructInsert(myLookupTable,&quot;213&quot;,&quot;Real text 1&quot;);
   StructInsert(myLookupTable,&quot;234&quot;,&quot;Real text 2&quot;);
   StructInsert(myLookupTable,&quot;456&quot;,&quot;Real text 3&quot;);
           :
</CFSCRIPT>

<CFSET myRealText = myLookupTable[FORM.cmbKodMukim];

<CFOUTPUT>For the Combobox selection #FORM.cmbKodMukim#, the text I'm really after is #myRealText#</CFOUTPUT>



-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top