Solved

CFSELCT and passThrough

Posted on 2003-11-17
13
691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

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 …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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