html - Jquery calculation price of hotel and room with additional price -


demo : http://jsfiddle.net/sando779/16wws4w1/

<select name="one" id="one">      <option value="0">select hotel</option>      <option value="3000">nirvana</option>      <option value="6000">laguna</option>      <option value="9000">palm beach</option>  </select>  <br />  <br />  <select name="two" id="two">      <option>room type</option>  </select>  <br/>  <br/>  <p>  <input type="checkbox" name="tri" id="tri" value="50"/>      <label >additional price</label>  </p>  <div id="total"></div>

// arrays instead of comma separated list , added base key  var data = {      "0": ["select room type"],          "3000": ["economist_0", "executive_465", "businesse_984"],         "6000": ["economist_200", "executive_700", "businesse_800"],          "9000": ["economist_400", "executive_800", "businesse_900"]  }    $("#one").change(function () {      var first = $(this),          second = $("#two"),          third = $("#tri"),          key = first.val(),          // instead of original switch code          vals = data[key] == undefined ? data.base : data[key],          html = [];      // create insert html before adding      $.each(vals, function (i, val) {          var v = val.split('_');          html.push('<option value="' + v[1] + '">' + v[0] + '</option>')      });      // no need empty element before adding new content      second.html(html.join());  });    $("#one,#two,#tri").change(function () {      var val1 = parseint($('#one').val()) || 0,          val2 = parseint($('#two').val()) || 0,          val3 = parseint($('#tri').val()) || 0;      $('#total').text(val1 + val2 + val3)  })

i'm wanna sum values different types of form elements. drop down , input. i'm stuck @ total not automate update after add additional price

you adding additional value if checkbox not checked. need add additional value if checkbox checked. can try jsfiddle http://jsfiddle.net/16wws4w1/1/


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -