Saving select box elements to a database

ok, I’ve conquered buttons and checkboxes working in forms and saving/retrieving values from a database. Now, I’m trying to get my select boxes to do the same. The select box, name and value elements are manually entered in the properties panel. I tried to asssign the value and the name dynamic attributes to fields in the database to retrieve and store but that’s not working. Can you please guide me. I’ve re-read the doc on select menus but that didn’t really help with what I was trying to do.
The problem I see is that when I go to the server connect side and get global post fields using the by input from form option, I don’t see a field for the select box. That’s weird. Shouldn’t I be seeing something?

Rick

Hello,
Make sure your select menu has a name and id assigned.
Import your form fields in the server action and you will see the select menus under POST vars, just as any other field on the page.

got it work however only when the values are different. I have a case where I have three items variations all priced the same. The manual entries in the properties panel read different text but the same value field. I thought I could use the name field which allows me to select the selected index but I can’t seem to get that to work. Any advise. Of course, this had to be the first select box I tried, so it wasn’t until I changed the values that I realized it works in most ordinary cases. Is there a way to use the selected index to store and retrieve the selected text/value combinations for the select box?

Rick

I am not sure I understand what exactly are you referring to?
What is the same and what is different?

the table looks like this:
name value
disk 500
flash drive 500
digital download 500

so the value which is stored is always 500. When the data is retrieved from the database, it has no idea which name was actually chosen.

The selected index would be 1,2,3 but I can’t seem to assign that to anything.

Rick

Sorry, but I’m lost :slight_smile:
Can you explain step by step what EXACTLY are you trying to achieve? Are you trying to store the values in the database or to read them and make the selected value active?? Or are you trying to create dynamic dropdown menu?
It’s really unclear the way you are explaining it…

Sorry im confusing this. What i am doing is creating a form to generate job quotes. I have a series of select boxes to choose different types of services. These are not menus but data entry for fields in a database which stores the form. I also need to retrieve the form with all options shown as selected to allow updates. All of my select boxes have unique text value combos except for one box which is where in having trouble. When i retrieve the data from the database to populate the select boxes, all work except the one where the values are the same like the table i sent. I was hoping to store and select the indexedvalue of the box to distinguish which row was selected but cant. Does that make sense?

Maybe a link or some screenshots would help?

Is what are you trying to explain that you have a dropdown with all values the same?
And you store these values in a database, then trying to retrieve them?
Something like:

<select>
 <option value="500">Disk</option>
 <option value="500">Flash drive</option>
 <option value="500">Digital download</option>
<select>

If that’s the case, I’m sorry but that’s a really bad database design.

Dropdown values must always be unique, you cannot use the same values.

Thanks Teodor, you’re right this doesn’t make sense. I thought that you had access to all three variables in a select box, the selected index, the value, and the name. Since the prices are the same here, i can’t do it this way without an index.

Your comment does make me wonder if what I’m doing with radio and checkboxes is a bad approach even though it works. I’m just trying to create the simplest touch enabled form for my wife to fill out without much effort while she has a client in front of her.

What would the preferred way be to have an easy input design for say choosing a product, then 3 variations of a product, each of which has three prices. I want to be able to store the name of the product / variation chosen and it’s price.
Should I not be using checkboxes or radio buttons for this?

I appreciate your input, love your product and don’t take offense telling me that I’m barking up the wrong tree.

Rick

Not sure what checkboxes and radio buttons are you referring to? I thought we were discussing how to store select menu value to the database and then retrieve it? Isn’t that the case?

What i am saying is that your select menu values you send to the database must be unique, usually these are some IDs you store in the DB and retrieve the values related to these IDs (name, price).

Like:

<select>
 <option value="1">Disk</option>
 <option value="2">Flash drive</option>
 <option value="3">Digital download</option>
<select>

yes we were talking about select boxes. I was referring to the entire form which uses select boxes, checkboxes and radio buttons for data entry. I got everything to work and it looks great.

I’ll ask a new topic regarding printing in a minute.

Thanks,
Rick