Skip to main content
Participant
May 23, 2008
Question

2 values from just one dropdown

  • May 23, 2008
  • 2 replies
  • 377 views
Hello,

I am using cf 8. and still realitively new at CF.

I have a dropdown for products a, b and c (with their corisponding values) i.e.
<option value="150">a</option>
<option value="200">b</option>
<option value="250">c</option>

When the user selects either a, b or c item in the dropdown i would like not ONE value to be posted but TWO.

i.e. 2 option values posted per selection rather than one.

It seems obvious that dropdowns may only have ONE value assigned to each selection.

If this is the case I thought of creating a second input selection that would be dependant on the first selection. Make the second selection hidden and when the entire form is submitted, the first visable dropdown and the hidden dropdown inputs will be submitted with 2 values respectively. does this sound crazy? Is there an eisier way to do what I am trying to accomplish?

If this is the only(or easiest) way to go, can someone point me in the right direction?

i google'ed this problem but got back suprisingly complex results that isn't quite tailored for my problem by a long shot. What I stumbled across were "dependant dropdown" code that was messy & and confusing to a beginner like me.

Any help would be appriciated.

PCchief

This topic has been closed for replies.

2 replies

Inspiring
May 23, 2008
You can have selects that allow multiple selections. I personally dislike them. If there are not that many choices, I prefer check boxes.
Inspiring
May 23, 2008
it's true a select option can have only one value, but that value can be
anything you want!

you could have <option value="150|xyz">a</option>, for example, and then
on form submit you can use cf list functions to get the two (or more!)
parts of the value.

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
PCChiefAuthor
Participant
May 24, 2008
Thanks both for replying so soon!

To refine my question a little further I have the dropdown selection with 17 products (I only list 3 here)...dropdown is the only option for me here.
<option value="150">a</option>
<option value="200">b</option>
<option value="250">c</option>
etc.etc.etc
The reason why i need to have two values on this one dropdown is that I am submitting the values to a distribution company in the form of xml.

everything works great for the one value when it is submitted THEIR server...and I get the correct response back..

however as i mentioned..i need to submit the classes + weights of each of my individual 17 products.

the values you see 150...200...250 are the "classes" for the products ...

you stated i can have 2 values in one ...i.e. <option value="150|xyz">a</option> and then seperate them upon submitting of the form? You mention the "cf list functions"..a pointer would be helpful.

So, if I were to use the option value you wrote "150|xyz" with what i need i.e. "150|1200" is there a way to break the two values up to place them in the two feilds of the xml upon submittion of the form like below?

<SHIPPING>
<CLASS>#form.class#</CLASS>
<WEIGHT>#form.weight#</WEIGHT>
</SHIPPING>

I hope im not confusing. thanks again in advance.