Solved

CFSELCT and passThrough

Posted on 2003-11-17
13
688 Views
Last Modified: 2013-12-24
HI,

I am querying my database for my drop down list in my form using CFSELECT.

-Some tables to know (MSACCESS BTW)
------------------------------------------------------------------
tblSoft
SoftID         autonumber    primarykey
Title            Number
-----------------------------------------------------------------
tblLicense
LicenseID       autonumber    primarykey
LicenceType
-----------------------------------------------------------------
tblJunction
SoftID             Number
DeptID            Number
LicenseID        Number
CustID            Number
JunctionID       autonumber    primarykey
----------------------------------------------------------------


Ok, this is the queries on my form page.

<!---------------------------------This is the department query --------------------------->
<cfquery name="department_query" datasource="softtrack">
SELECT *
FROM tblDept
WHERE DeptID=<cfqueryparam cfsqltype="CF_SQL_INTEGER"
       value="#url.DeptID#">
</cfquery>
<!-----------------------------------Deparmemnt Query Ends Here---------------------------->
<cfquery name="querysofttype" datasource="softtrack">
SELECT * FROM tblLicense ORDER BY LicenseID
</cfquery>


<cfquery name="querysofttitle" datasource="softtrack">
SELECT *
FROM tblSoft
ORDER BY SoftID

</cfoutput><cfform name="Addsoft" action="check.cfm" method="post">
           <cfselect name="Title" message="Please Enter A Software Title." query="querysofttitle" value="Title" required="yes" passthrough='SoftID="SoftID"'></cfselect>
       
        <cfselect name="LicenseType"message="Please Select A License Type" query="querysofttype" value="LicenseType" required="yes" passthrough="LicenseID">
                             
        <cfinput name="HowMany" type="text" size="3" required="yes" message="Please Enter How Many Licenses" id="Count">


                  <cfquery name="getid" datasource="softtrack">
            SELECT DeptID
            FROM tblDept
            WHERE DeptID=<cfqueryparam cfsqltype="CF_SQL_INTEGER"
       value="#url.DeptID#">
            </cfquery>
        <input name="DeptID" type="hidden" value="#DeptID#"></cfoutput>
         <input type="submit" name="Submit" value="Update">
        <input type="reset" name="Submit2" value="Reset">          
     
    </cfform>


This is what is happening and what I need help with

The drop down list will have software titles from the database, the software titles in the database have primary key ID, the field is named SoftID

I need to pass the vaule of SoftID when a software title is choosen.

I asked for help in another thread when I first started to figure how I wanted to do this, but no one has got back to me yet, you can look here for reference.

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_20794716.html





0
Comment
Question by:fixx17
  • 7
  • 5
13 Comments
 
LVL 6

Accepted Solution

by:
PE_CF_DEV earned 500 total points
ID: 9765786
what you want to do is use the display= for the title then the value= for the value you want the selected option to be passed.  the passthrough thing is used to pass additional HTML into the select attribute like passthrough="onclick='dostuff'"

CHeck here for more info on <cfselect>:

http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-pc2.htm
0
 
LVL 1

Author Comment

by:fixx17
ID: 9766207
Thanks, I will test this out right now.

I appreciate your help, I had my reference book open, but it did not give good examples.  I will get back to you soon.

0
 
LVL 1

Author Comment

by:fixx17
ID: 9766263
Ok, it seemed like the Display=Title worked, but it but the vaule did not hold for some reason.  It did not throw an error, but the SoftID and LicenseID did not pass the number.

Is there anything that I could have missed.

My cfinsert on the next page looks like this.

<cfinsert datasource="softtrack" dbtype="ODBC" tablename="tblJunction" formfields="DeptID, SoftID, LicenceID, HowMany">
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9766311
at the top of the page with the cfinsert in it try

<cfdump var="#form#">

And make sure the correct values are being passed. if they are then fix your insert ;) if not post your revised code for the form and we'll get ya fixed up :)
0
 
LVL 1

Author Comment

by:fixx17
ID: 9766432
That was cool!

Yes, it seems that the vaules are being passed (that was awsome by the way, it made me chuckle)

This is what it looked like.

DeptID | 5
FieldNames | Title,LicenseType,SoftID,DeptID,Submit
HowMany | 50
LicenseType | 4
Submit | Update
Title | 3

I have to make a mental note of <cfdump var="form">

I just can't figure out what those numbers (or vaules) are inserted into those fields.



0
 
LVL 1

Author Comment

by:fixx17
ID: 9766472
OH, my insert is this BTW

<cfinsert datasource="softtrack" dbtype="ODBC" tablename="tblJunction" formfields="DeptID, SoftID, LicenceID, HowMany">
0
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9766474
I never use cfinsert...I just code the SQL instead

<cfquery name="insertstuff" datasource="softtrack">
Insert INTO tblJunction (column names here)
VALUES (#form.DeptID#, #formSoftID#, #formLicenceID#, #formHowMany#)
</cfquery>
0
 
LVL 1

Author Comment

by:fixx17
ID: 9766568
If I do it the way you posted it above, I get an error now.

An error occurred while evaluating the expression:


#form.SoftID#


Error near line 6, column 25.
--------------------------------------------------------------------------------

Error resolving parameter FORM.SOFTID


The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name

I double checked and there are no mis spellings.
0
 
LVL 1

Author Comment

by:fixx17
ID: 9766621
Sorry, I did add the #form.SoftID#

What I am tyring to say is that I noticed you did not put the dot between form and SoftID and the rest, I fixed this before I tested it and got the same errors.
0
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9766903
i think its becuase in the dfdump you showed the softID is acutally named Title try form.title in the place of form.softID and that might be the right value.
0
 
LVL 11

Expert Comment

by:hart
ID: 9768985
i have posted a comment in ur earlier question...

and for the insert do this

<cfquery name="insertstuff" datasource="softtrack">
   Insert INTO tblJunction (SoftID,DeptID,LicenseID,HowMany)
   VALUES (#form.Title#, #form.DeptID#, #form.LicenseType#, #form.HowMany#)
</cfquery>

Regards
Hart
0
 
LVL 1

Author Comment

by:fixx17
ID: 9771164
PE_CF_DEV, I checked the naming convention for CFSELECT NAME-BLAH,

I had to rename them to CFSELECT Name="SoftID" and CFSELECT NAME="LicenseID"

For some reason, it finally dropped all the ID numbers in the tblJunction.

This is the finall code what I have

<!-------------------------Here is the form-------------------------------------------->
<cfform name="Addsoft" action="check.cfm" method="post">
         <cfselect name="SoftID" message="Please Enter A Software Title." query="querysofttitle" value="SoftID" display="Title" required="yes"></cfselect>
           <cfselect name="LicenseID"message="Please Select A License Type" query="querysofttype" value="LicenseID" display="LicenseType" required="yes">
                       </cfselect>
       
        <cfinput name="HowMany" type="text" size="3" required="yes" message="Please Enter How Many Licenses" id="Count">
   
                          <cfquery name="getid" datasource="softtrack">
            SELECT DeptID
            FROM tblDept
            WHERE DeptID=<cfqueryparam cfsqltype="CF_SQL_INTEGER"
                       value="#url.DeptID#">
            </cfquery>
        <cfoutput query="getid"><input name="DeptID" type="hidden" value="#DeptID#"></cfoutput>
             
         <input type="submit" name="Submit" value="Update">
        <input type="reset" name="Submit2" value="Reset">            
        </cfform>

<!-----------------------Here is the CFINSERT that the form calls for on submit-------------------------------->
<!-------the CFDUMP was yours, thanks for showing me that----------------->
<cfdump var="#form#">

<cfinsert datasource="softtrack" dbtype="ODBC" tablename="tblJunction" formfields="DeptID, SoftID, LicenseID, HowMany">


Drops everything in the table just right,

Thanks for sharing the VAULE and DISPLAY Attributes.
0
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9771293
Glad it is all working out and glad I could help :-))
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migration from IIS6 onto IIS7 6 53
Problem to Eclipse 16 125
Problem to go to page 12 93
SSL Certificate for IIS7 Site 2 19
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question