JavaScript javascript drop down menus returning a value javascript drop down menu,javascript drop down select,javascript drop

been using the site for a while - first time posting.

I have a problem i am trying to solve. in Javascript (not jQuery or AJAX) i am trying to have 2 drop down menus, and a third field returning an integer based on the two drop-downs. So i have Dropdown menu 1, when the user selects a value from that menu the second dropdown will display the relevant items - this i have running fine using an example i found here: Populate one dropdown based on selection in another

However i now need to be able to pull a value out based on the selection in the second drop-down menu. For instance the user selects an "Audi" in the first menu, then "A4" in the second menu and is then shown the price of that specific item.

im at a total loss with this one, been trying to use the index off the second dropdown menu - once a user has selected the third item the index should return "4" i could then set-up another array to switch that "4" to the value i want - but that seems clunky.

In my initial tests for my menu's i was using this array:

    stone_category = 0;
 stone_category["Granite & Marble"]=1;
 stone_category["Sensa Granite"]=2;
 stone_category["Silestone Quartz - Polished Finish"]=3;
 stone_category["Silestone Quartz - Leather & Volcano Finish"]=4;
 stone_category["Eco Recycled Surfaces - Polished Finish"]=5;
 stone_category["Caesarstone Quartz - Polished Finish"]=6;
 stone_category["Unistone Quartz - Polished & Leather Finish"]=7;
 stone_category["Samsung Radianz Quartz - Polished Finish"]=8;
 stone_category["Okite Quartz - Polished Finish"]=9;
 stone_category["Compac Quartz - Polished and Matt Finish"]=10;

And from that i could pull the numeric value to use in a calculation. however the way i then had to set up my drop-down menus that style of array doesnt work for the second menu leaving me at the loss i am at now.

i hope i have explained clearly enough.

Answer:1

You could add an extra attribute to those elements, something like category-id="x", where x is the value you want to pull from each. Then you can grab that value with a selector:

value = document.querySelector("#submenu .checked").getAttribute("category-id");

Change #submenu and .checked with whatever classes or selectors you add to the submenu and selected items.

Answer:2

I have a log like t=2016-08-03T18:47:26+0000 lvl=dbug msg="Event Received" Service=SomeService and I want to turn it into a javascript object like { t: 2016-08-03T18:47:26+0000, lvl: dbug ...

I have a log like t=2016-08-03T18:47:26+0000 lvl=dbug msg="Event Received" Service=SomeService and I want to turn it into a javascript object like { t: 2016-08-03T18:47:26+0000, lvl: dbug ...

  1. javascript regex split by character
  2. javascript regex split string into array
  3. javascript regex split multiple delimiters
  4. javascript regex split on whitespace
  5. javascript regex split string into words
  6. javascript regex split string
  7. javascript regex split csv
  8. javascript regex split camelcase
  9. javascript regex split
  10. javascript regex split url
  11. javascript regex split newline
  12. javascript regex split example
  13. javascript regex split by space
  14. javascript regex split lines
  15. javascript regex split sentences
  16. javascript regex split comma
  17. javascript regex split number
  18. javascript regex split group
  19. javascript regex split not working
  20. javascript regex split every 2 characters

I've got a table with a number of items. I'm trying to show input fields when a user clicks on an edit button, but I don't know how to select only the element within the same row as the edit button. ...

I've got a table with a number of items. I'm trying to show input fields when a user clicks on an edit button, but I don't know how to select only the element within the same row as the edit button. ...

Hey guys i am trying to create empty array in react-native using es6. But while accessing it i get an error data not defined. Here is the code snippet which i am using to initialise the array. ...

Hey guys i am trying to create empty array in react-native using es6. But while accessing it i get an error data not defined. Here is the code snippet which i am using to initialise the array. ...

  1. initialise array react
  2. initialize array react
  3. initialize array react native

I have an array eg: a[3,4,5,6,7,8]. I want to remove all the element in one time and make array as an empty array. How to remove all the element of an array. My code var a = [2,3,4,5,6]; for(var i=...

I have an array eg: a[3,4,5,6,7,8]. I want to remove all the element in one time and make array as an empty array. How to remove all the element of an array. My code var a = [2,3,4,5,6]; for(var i=...

  1. remove elements from list python
  2. remove elements from array
  3. remove elements from a list
  4. remove elements from array java
  5. remove elements from array matlab
  6. remove elements from array python
  7. remove elements from vector c++
  8. remove elements from numpy array
  9. remove elements from dictionary python
  10. remove elements from vector r
  11. remove elements from list java
  12. remove elements from list r
  13. remove elements from array ruby
  14. remove elements from string python
  15. remove elements from set python
  16. remove elements from string
  17. remove elements from array c#
  18. remove elements from dom
  19. remove elements from list python by index
  20. remove elements from np array