Solved

CFSELCT and passThrough

Posted on 2003-11-17
13
683 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
 
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
Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

17 Experts available now in Live!

Get 1:1 Help Now