javascript - how to make function which related comboboxes option -


in html page there 3 form input has been related each other. first input combobox option:

  • tca
  • intasept second , third input text type.

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

on simple logic.

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

this continue interval 120. ex:

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

if in first input = intasept (selected option user).

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

ex:

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

help me how make function in javascript. this, have tried not run

var interval, step; $("#first").change(function (e) {     if (this.option:selected) interval = { // map of input value attributes 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/

http://jsfiddle.net/qxfkl/5/

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

but value getting "intesept" casesensitive

also if didnt work i've removed it


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -