Solved

CFSELCT and passThrough

Posted on 2003-11-17
13
682 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 6

Expert Comment

by:PE_CF_DEV
Comment Utility
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
Comment Utility
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
Comment Utility
OH, my insert is this BTW

<cfinsert datasource="softtrack" dbtype="ODBC" tablename="tblJunction" formfields="DeptID, SoftID, LicenceID, HowMany">
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 6

Expert Comment

by:PE_CF_DEV
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad it is all working out and glad I could help :-))
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now