|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Passing autonumber using <SELECT>
Stupid question....
I think I'm having a mental meltdown or something cause I know I've done this before, but for the life of me I am at a brick wall! I have a form (form1.cfm) that uses a <select> box pre-filled via DB that a user chooses to get details on. I have set the <option value="#record_id#"> and have the form passing id on url, but will only pull up the first Record ID no matter which one I choose? I am using a cfoutput. What the heck have I missed in order to get each rec_id to pass with the chosen record????? PLEASE HELP! ![]() |
|
#2
|
||||
|
||||
|
Look at your HTML output source and make sure that the values for the options are unique.
If they are, then post some of your code, especially for whatever you're posting the form to. |
|
#3
|
|||
|
|||
|
You're probably not looping over the query and populating the select box correctly.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
Select box ok
The select box is populating fine. It is when the form posts that I can only get the first record id value even if I choose record 83 in the select box. I am not using a CFLOOP. Here is the code I have currently:
<CFQUERY NAME="phone_byname" DATASOURCE="innet"> Select phone_fname, phone_lname, phone_id, fax_switch From phone_fax Where phone_lname IS NOT NULL AND phone_fname IS NOT NULL Order By phone_lname ASC </CFQUERY> <FORM ACTION="phone.cfm?action=phlkup&phone_id=<CFOUTPUT>#phone_id#</CFOUTPUT>" METHOD="post"> <INPUT TYPE="Hidden" NAME="phone_id" VALUE="#phone_id#"> <INPUT TYPE="Hidden" NAME="fax_switch" VALUE="#fax_switch#"> <INPUT TYPE="Hidden" NAME="phone_lname" VALUE="#phone_lname#"> <INPUT TYPE="Hidden" NAME="phone_fname" VALUE="#phone_fname#"> <B>Search by Name:</B><BR> <SELECT NAME="phone_selectname" SIZE="1"> <OPTION SELECTED VALUE="0">Choose Name</OPTION> <OPTION VALUE="all">All</OPTION> <CFOUTPUT QUERY="phone_byname"> <OPTION VALUE="#phone_id#"> #phone_fname# #phone_lname#</OPTION> </CFOUTPUT> </SELECT><INPUT TYPE="Submit" VALUE="Find"> </FORM> After a record is chosen, say record 43, the form redirects and on the url is ALWAYS phone_id=1. The data outputs for record id 1. I just don't know why the heck I cannot pass phone_id #anything-but-1#??? |
|
#5
|
|||
|
|||
|
Given the code you have written, how can it be anything except 1? Look at what you are doing:
<FORM ACTION="phone.cfm?action=phlkup&phone_id=<CFOUTPUT>#phone_id#</CFOUTPUT>" METHOD="post"> This will always pass the first record in the recordset in the URL. The user isn't picking anything. What you want to do is remove the phone_id URL variable and let the user pick it in the form, which will pass the phone_id as a FORM field. You should not be passing this in the form action's URL if you want the user to pick it in the form. |
|
#6
|
|||
|
|||
|
Quote:
I tried that originally. I even left the hidden form field for phone_id (autonumber). That's why I said I knew this should be a simple thing, but I am baffled why it is ending up a major process. I include it on the recieving template in the query as: <cfif action IS "phlkup"> <CFQUERY NAME="phone_choice" DATASOURCE="innet"> Select phone_fname, phone_lname, dept, phone_ext, phone_id, fax_switch From phone_fax Where phone_id = #form.phone_id# This is the error I get: ODBC Error Code = 37000 (Syntax error or access violation) [Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression 'phone_id = #phone_id#'. SQL = "Select phone_fname, phone_lname, dept, phone_ext, phone_id, fax_switch From phone_fax Where phone_id = #phone_id#" Notice that it states error in DATE ????? It is an autonumber?? Nothing refers to date format anywhere. Also note that this does not show the actual coding of #form.phone_id#???? Not only this, but I have included the following as the first thing on the page: <CFIF #IsDefined("url.action")#> <cfset action = "phlkup"> <cfoutput>phone_id: #form.phone_id#</cfoutput> </CFIF> Nothing comes up for form.phone_id???? It is blank..... ![]() |
|
#7
|
|||
|
|||
|
I just KNEW it was something stupid! I was asking for form.phone_id, but that was the VALUE of the select field so I really needed form.phone_selectname which is where the phone_id values were held!
where phone_id = #form.phone_selectname# DUH! I can finally sleep!! Thanks for all the help and insight. I am really glad I happened on this site today because I have posted issues in the past at other places and never received a response of any kind. Thanks for your blatant honesty kiteless...(how can it be anything except 1?) I knew this, but couldn't see what I was doing until you wrote it. I'll be baaaackk! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Passing autonumber using <SELECT> |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|