html - Complex Jquery show / hide -


background: i'am trying make form shows , hides boxes depening on user clicked. thing makes complicated there multitude of states controlled 2 click events.

problem:

1 user has either input energy , gas usage 2 energy usage, or 3 let system make guess energy , gass usage or 4 let system guess energy usage.

depending on user clicked correct input , select boxes should show up:

initial: -> energy , gass usage input displyed, user clicks 'guess consumption' -> select boxes displayed

initial: -> energy , gass usage input displyed, user clicks 'compare energy only' -> gas input dissapears, text compare energy re-appears, user clicks 'compare gas well' -> gas input re appears

all of above works, doesnt work:

initial: -> energy , gass usage input dispalyed, user clicks 'guess consumption' -> select boxes displayed, user clicks -> 'compare energy only', select box gas dissapears, user clicks -> know consumption only 'energy input appears', user clicks compare gass well, inputs don't match anymore 1 input box , other selectbox while should same.

i know it's specific tried best give details here jsfiddle:

https://jsfiddle.net/nsbr4vct/6/

jquery(document).ready(function($) { $(".cw_txt_ookgasvergelijken").click(function() {     if ($(this).hasclass('actief'))          $(this).text('compareenergyonly'),         $("#statuscheck").val(2);        else         $(this).text('comparegasaswell'),         $("#statuscheck").val(1);       $(this).toggleclass('actief');       $(".cw_left_toggle").toggle(400);      $("#gas_div").val("");  });  $(".cw_txt_inschatten").click(function() {     if ($(this).hasclass('actief'))         $(this).text('guess consumption');      else         $(this).text('iknow consumption');     $(this).toggleclass('actief');      $(".cw_a1").toggle(400),         $(".cw_a2").toggle(400);     });    $(".cw_txt_inschatten").click(function() {     if (!$(".cw_txt_ookgasvergelijken").hasclass('actief'))            $(".cw_a3").toggle(400),         $(".cw_a4").toggle(400),         $(".cw_a4").toggleclass('actief');     });   $(".cw_txt_ookgasvergelijken").click(function() {     if ($(this).hasclass('actief') && $(".cw_a4").hasclass('actief'))         $(".cw_a4").toggle(400);  }); 

});

    <div id="container"> <div id="cw_vergekijker_input_container">    <form id="form">       <div class="cw_center">           <div class="cw_left cw_stroominschattena">             <div class="cw_a1">energy<br><input class="cw_vergelijker_input cw_input_stroom" type="text" name="stroom" placeholder="3600" maxlength="7" onfocus="this.placeholder = ''" onblur="this.placeholder = '3660   kwh'" /><span class="prefill_stroom_gas">kwh</span></div>             <div class="cw_txt_inschatten stroom_txt"><a href="#">guess consumption</a></div>          </div>          <div class="cw_left cw_stroominschatten">             <div class="cw_a2">guess energy<br><select class="cw_vergelijker_input cw_input_stroom" type="text" name="stroom" placeholder="3600" maxlength="7" onfocus="this.placeholder = ''" onblur="this.placeholder = '3660   kwh'" /></select></div>          </div>          <div class="cw_left_toggle gas">             <div class="cw_a3"><span class="toggle">gas</span><br><input id="gas_div" class="cw_vergelijker_input cw_input_gas" type="text" maxlength="7" name="gas" placeholder="1430" onfocus="this.placeholder = ''" onblur="this.placeholder = '1430'"/><span class="prefill_gas">m3</span></div>          </div>          <div class="cw_left cw_stroominschatten">             <div class="cw_a4">guess m3 rate<br><select class="cw_vergelijker_input cw_input_stroom" type="text" name="stroom" placeholder="3600" maxlength="7" onfocus="this.placeholder = ''" onblur="this.placeholder = '3660   kwh'" /></select></div>          </div>          <input id="statuscheck" class="hidden" name="statuscheck" type="text">          <div class="cw_left">             <input type="submit" name="vergelijken" value="vergelijken" class="cw_vergelijker_submit">             <div class="cw_txt_ookgasvergelijken"><a href="#">compare energy only</a></div>          </div>       </div>    </form>    <div style="clear: both" /></div> </div> 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -