-2

So i have these options.

<option value="bentley">Bentley</option>
<option value="ferrari">Ferrari</option>
<option value="honda">Honda</option>
<option value="toyota">Toyota</option>
<option value="peugeot">Peugeot</option>
<option value="citroen">Citreon</option>

If i click on honda, the honda cars are displayed. IF toyota then toyotas..and so on.

I would like to make an option, where i only reference the luxury cars. Just do not know how to make it work.

<option value"ferrari:bentley">Luxury cars</option>

Any ideas?

Note: It can help others, who would like to reference more than one value in an option. As I was searching around for 1.30 hours there is not much out there.

Thank you in advance

  • you mean to say when you select `Luxury cars` you want `ferrari` & `bentley` as values ? – krishna May 14 '14 at 10:21
  • 1. what does this have to do with php, js, jquery and css? 2. what's wrong with ` – Catalin Deaconescu May 14 '14 at 10:23
  • ok, sorry, have deleted css and jquery....because the ferrari, bentley are already in the database, that is why i want to use them...the one which i have wrote does not work somehow – user3633363 May 14 '14 at 10:28
  • @user3633363 if what i understand is correct, i think you (and your users) would be better server if you would have a checkbox for "Luxury cars" that would limit the existing select menu to the makes that you want (could also add an "All" option). Otherwise, i would still suggest using the numbers as values, as it will let you quickly identify the option selected and allow you to assign whatever you want to that number in the backend programing – Catalin Deaconescu May 14 '14 at 10:34
  • so there is no simple solution, where i make another option which send to the server the two values? theme: http://bizzthemes.com/preview/?theme=2808 that is what i am trying to modify...after pickign the date there is time to pick the cars – user3633363 May 14 '14 at 10:43
  • 1
    What you should do is probably in database where you store cars types create on column named as Class and give it values like `Luxury`,`SUV`,.. so when customer books a car based on class you should allocate him cars. If you could provide us the table structure we could help more for your case – krishna May 14 '14 at 10:47

3 Answers3

0

You could use an optgroup

JSfiddle

<select name="carss">
    <optgroup label="Luxury cars">
        <option>Ferrari</option>
        <option>Bentley</option>
        <option>Rolls Royce</option>
    </optgroup>
    <optgroup label="Others">
        <option>Honda</option>
        <option>Ford</option>
        <option>Toyota</option>
    </optgroup>
</select>
Paulie_D
  • 107,962
  • 13
  • 142
  • 161
0

For multiple values in option tag use below code

 <option value="{'num_sequence':[0,1,2,3]}">Option one</option>
 <option value="{'foo':'bar','one':'two'}">Option two</option>

First one is using array and second one is using Object.

Refer this for more info.

Community
  • 1
  • 1
shyammakwana.me
  • 5,562
  • 2
  • 29
  • 50
0

You should do like this

  1. create a Table with Car names and its type like Luxury,Sedan,etc.

  2. Allow users to select cars based on types or car name.(dont combine both)

  3. Then when user select Cars by type you need to get cars from first table corresponding to that class name

krishna
  • 4,069
  • 2
  • 29
  • 56
  • i am trying to add the code for this theme: http://bizzthemes.com/preview/?theme=2808 ...so with that i dont think it will work...the values are already given once the website loads..so it would be better if i could just simple combine the two values – user3633363 May 14 '14 at 10:46
  • thanks for all...the theme already has database structure, and the way it has been built is that you can set the price only for the type of car, not for individual cars...therefore i would like a solution, which could make it happen without me touching the database.....the values which are in the options are the codes/slugs for the cars...so if i could make it that i call all the slugs for the cars, then would be great...therefore i wanted the multiple option values solution – user3633363 May 14 '14 at 11:00
  • its kinda complicated...could you send me ur email at freelander@collector.org...so ican send you the login details so you can take a look and see if you could help me with compensation..thanks – user3633363 May 14 '14 at 11:04