Skip to main content
Participant
November 6, 2010
Answered

How to save value chosen in select?

  • November 6, 2010
  • 1 reply
  • 1599 views

How can I save the value chosen from a select box in a form and save it to a parameter to be passed to an action page? Below is the code to make the drop down box. I have a query earlier in the code that populates the list with the MovieTitle field from a database of films. It works well, brings up the list and holds the choice in the box. But I am not saving it anywhere and need to. Can't figure out how.

<!--- Movie list for drop down box --->

  <select name="MovieTitle"
     <option value=""></option>
        <cfoutput query="movie_list">
         <option value="#FilmID#">#MovieTitle#</option>
        </cfoutput> --->

Thanks for any help!

woodsie

This topic has been closed for replies.
Correct answer Dave Watts

Well, if all you really wanted was the film title, you could specify that in the option's value attribute instead of FilmID. But often, we want to use primary keys to guarantee uniqueness and to make things easier in other respects. If that's the case, your action page could fetch the corresponding title from the database using the FilmID as a filter within your query. Which of these is the best approach really depends on what else is going on in your pages.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

1 reply

Community Expert
November 6, 2010

In your FORM tag, you probably have an ACTION attribute that points to another CF page and a METHOD attribute with a value of POST. When you click the submit button in your form, the browser will automatically send all of the form fields and their corresponding values to the CF page specified in your ACTION attribute.

With the sample code below, you'd end up with a variable in the action page called Form.MovieTitle with a value of whichever FilmID the user selected.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

Dave Watts, Eidolon LLC
Participant
November 6, 2010

That helps a great deal! I added #FORM.MovieTitle# to my action page. Of course, as you pointed out it passed the FilmID and displays the record id of the Film instead of the title. Can I can the select to pass the movietitle itself? Or should I use the passed FilmID in a query on the action page? thanks very much for your help, woodsie.

Dave WattsCommunity ExpertCorrect answer
Community Expert
November 6, 2010

Well, if all you really wanted was the film title, you could specify that in the option's value attribute instead of FilmID. But often, we want to use primary keys to guarantee uniqueness and to make things easier in other respects. If that's the case, your action page could fetch the corresponding title from the database using the FilmID as a filter within your query. Which of these is the best approach really depends on what else is going on in your pages.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

Dave Watts, Eidolon LLC