Solved

CFSELCT and passThrough

Posted on 2003-11-17
13
689 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

838 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