Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Select list parameters

Status
Not open for further replies.

tina2

IS-IT--Management
May 1, 2001
169
0
0
US
OK this must be really simple, because I am not seeing anyone else with this problem:
I have a dropdown list that is dynamically generated from a database. I am trying to pass the value of the selected item on the URL, but the URL will only pass the value of the first item on the list. Can somebody tell me what I am missing? Is there a better way of passing the parameters without the URL?

Code:
------------Form Action----------------
<cfform action=&quot;Policy_Details.cfm?PolicyID=#qGetPolicy.PolicyID#&quot; method=&quot;post&quot;>

-----------Select list----------------
<cfselect name=&quot;Policy_List&quot;>
<cfoutput query=&quot;qGetPolicy&quot;>
<option value=&quot;#qGetPolicy.PolicyID#&quot; name=&quot;PolicyID&quot;>#qGetPolicy.Name#</option>
</cfoutput>
</cfselect>

-------------Action Page Query----------------
<CFQUERY NAME=&quot;qGet_Policy_Details&quot; DATASOURCE=&quot;Database&quot;>
SELECT ClientID, PolicyID
FROM Policy
WHERE (PolicyID=#URL.PolicyID#)
</CFQUERY>

Thanks in advance!
Kristine
Newbie, obviously;-)
 
Hi Kristine,

You've actually done more coding than you need. As you have method=&quot;POST&quot;, you do not need any URL params, as the whole form is passed to the action template.

So you just need to remove the reference on the URL...

<cfform action=&quot;Policy_Details.cfm&quot; method=&quot;post&quot;>


... also, in the action form, you should reference the name of the select box, in this case &quot;Policy_List&quot; as this takes on the value of the option selected...

<CFQUERY NAME=&quot;qGet_Policy_Details&quot; DATASOURCE=&quot;Database&quot;>
SELECT ClientID, PolicyID
FROM Policy
WHERE PolicyID=#Policy_List#
</CFQUERY>

.. with that you should be fine!

( The reason you are getting only the first value is that the form line is built at the building of the page, and doesn't change whtever you do! ... view page source for proof!)

Hope this helps,

Kev

 
Thanks bigKev!

I knew it had to be simple!

Kristine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top