prbnk
prbnk

Reputation: 59

Link dropdown values with Buttons to select values of dropdown

Hi I want to design a dropdown such that it takes value range as 10, 20,30,50,70,100,150,200,300,700,1000,2000, and 5000. I also want two buttons for which I can assign value_up or value_down. which will get value range as mentioned above. Drop down will allow user to select values from above set manually where as value_up or value_down would allow to increase or decrease value for the above range. Could you please help me to achieve this using javascript? I have a basic functionality written here bu it is not doing the function as explained above.

Javascript:

var sensitivityFlag=0;

//// Sensitivity up ////
        function value_Up(){
            sensitivityFlag = 1;
        }

        //// Sensitivity down ////
        function value_Down(){
            sensitivityFlag = -1;
        }

        function sensitivity(x){
            sens = 1*x/1000;

            switch (sensitivityFlag){
        case -1:
            sensitivity_Down();
            break
        case 1:
            sensitivity_Up();
            break
        }

Upvotes: 0

Views: 61

Answers (1)

The KNVB
The KNVB

Reputation: 3844

To increase the "Sensitivity" value, you may refer my sample code here

function value_Up()
{
  var sensitivity=document.getElementById("sensitivitySelect");
  if (sensitivity.selectedIndex<(sensitivitySelect.options.length-1))
    sensitivity.selectedIndex++;
}

Upvotes: 2

Related Questions