Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make function which related comboboxes option

in my html page there are three form input has been related each other. first input as combobox with option:

  • TCA
  • Intasept second and third input as text type.

if first input fill is "TCA" when user input in second input "01" so in third input automaticly filled by "1-120". if first input fill is "intasept" when user input in second input "01" in third input automaticly fille by "1-32".

on simple logic.

  • first input = "TCA" (selected option by user).
  • second input = "01" (manually input by user).
  • third input = "1-120" (automaticly input).

this will continue with interval 120. ex:

  • second input: 02: 03 and so on.
  • third input : 121-240: 241-360 and so on.

if in first input = Intasept (selected option by user).

  • second input = 01 (manually input by user).
  • third input = 1-32 (automaticly input).
  • this will continue with interval 32.

ex:

  • second input : 02: 03 and so on.
  • third input : 32-64: 65-96 and so on.

help me how to make this function in javascript. this, what i have tried but this not run

var interval, step;
$("#first").change(function (e) {
    if (this.option:selected) interval = { // map of input value attributes to interval values
        "TCA": 120,
        "intasept": 32
    }[this.value];
    update();
});
$("#secondInput").on("change keyup input paste", function (e) {
    step = parseInt(this.value, 10);
    update();
});

function update() {
    if (isNaN(interval) || isNaN(step)) return;
    $("#thirdInput").val(((interval * step + 1)-interval) + "-" + ((interval * step + interval)-interval));
}

http://jsfiddle.net/n8pSt/

like image 298
icool Avatar asked May 15 '13 08:05

icool


People also ask

How do I use the combo box feature?

Add a list of items to the combo box and display an initial item in the selection field of the combo box. Detect when the user has selected an item from the combo box. Retrieve the selected item from the combo box.

How to create ActiveX control combo box in Excel?

Steps to create ActiveX Control Combo Box in Excel. Follow either of the 2 ways to view “New Name” dialog box –. Go to Formula tab -> click on “Name Manager” -> Click New in the “Name Manager” dialog box. OR. Go to Formula tab -> click “Define Name”. Enter Name, Months.

How to create a combo box in MicroStation?

Instructions. 1 Step 1: Create an instance of the combo box. The example application calls the CreateWindow function to create a child window of the application ... 2 Step 2: Load the combo box with the item list. 3 Step 3: Detect when the user selects an item and retrieve it from the combo box.

How do I create a combo box window in Salesforce?

Step 1: Create an instance of the combo box. The example application calls the CreateWindow function to create a child window of the application window. The WC_COMBOBOX window style specifies that it is a combo box.


1 Answers

http://jsfiddle.net/QXFKL/5/

if (this.option:selected) interval = { // map of input value attributes to interval values
    "TCA": 120,
    "intasept": 32
}[this.value];

but the value that you are getting is "Intesept" Casesensitive

also your if didnt work so I've removed it

like image 191
antpaw Avatar answered Sep 28 '22 07:09

antpaw