0

I have added 5 drop down fields in my form with the same name. These field will be displayed based on selected country's radio button.I have 5 radio buttons named as "USA,INDIA,UK,EURO,AUS".

If i select USA, 1st drop down contains US sizes, will be displayed. If i select INDIA,2nd drop down contains INDIAN sizes, will be displayed.

All are working Good. Now i have an issue with store that value to my DB in magento. When i submit the form, 5th drop down field(EURO sizes) value only saved.

If i select size other than EURO,I got an empty value. If i select Euro size, I got correct value.I hope you understand my problem. Please guide me to solve mine issue guys!

2
  • Using the same name for form fields is a really bad practice. Why should you do such thing? Commented Oct 21, 2013 at 6:13
  • because any one of size only will chose by customer from those 5 countries.i have selectsize field for to store that selected size.If i'll use different name for those drop down fields, i need to create 4 more field for to save that single value. I have no idea to achieve this task.so only i have used same name! Commented Oct 21, 2013 at 6:20

1 Answer 1

2

You can add disabled attribute to other drop-downs when you show the selected one. This way the browser will ignore the disabled ones.

Or, you could append [] to your drop-downs' name, like this:

<select name="name[]"> ... </select>

This way you will get an array in the request variable, then you can decide which to use in the array according to your radio button value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.