Advertisement
Guest User

Untitled

a guest
May 25th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.  
  3.     /* PROCESS SELECTED MENU ON START */
  4.     processSelect();
  5.  
  6.     /* PROCESS SELECTED MENU ON CHANGE */
  7.     $(".chzn-select").change(function (selected) {
  8.         processSelect();
  9.     });
  10.  
  11.     function Measure_Mode(that) {
  12.  
  13.         if ($(that).find("input#Measure_Mode").val() !== "3") {
  14.             $(that).find(".optional3").each(function () {
  15.                 $(this).find("input").val("");
  16.                 $(this).find("input").attr("value", "");
  17.                 $(this).fadeIn();
  18.             });
  19.         } else {
  20.             $(that).find(".optional3").each(function () {
  21.                 $(this).find("input").val("");
  22.                 $(this).find("input").attr("value", "");
  23.                 $(this).fadeOut();
  24.             });
  25.         }
  26.  
  27.         if ($(that).find("input#Measure_Mode").val() == "2") {
  28.             $("input#event").val(20);
  29.             $("input#event").attr("value", 20);
  30.             $(that).find(".optional2").each(function () {
  31.                 $(this).find("input").val("");
  32.                 $(this).find("input").attr("value", "");
  33.                 $(this).fadeIn();
  34.                 if ($(".chzn-select option:selected").val() == 5 || $(".chzn-select option:selected").val() == 6) {
  35.                     $("input#event").val(1);
  36.                     $("input#event").attr("value", 1);
  37.                 }
  38.             });
  39.         } else {
  40.             $("input#event").val(1);
  41.             $("input#event").attr("value", 1);
  42.             $(that).find(".optional2").each(function () {
  43.                 $(this).find("input").val("");
  44.                 $(this).find("input").attr("value", "");
  45.                 $(this).fadeOut();
  46.             });
  47.         }
  48.  
  49.     }
  50.  
  51.     function Whether_Connection_Event(that) {
  52.         if ($(that).find("input#Whether_Connection").val() == "1") {
  53.             $(that).find("#Meteorology").fadeIn();
  54.             $(that).find("#Temperature").fadeIn();
  55.         } else {
  56.             $(that).find("#Meteorology").val("");
  57.             $(that).find("#Temperature").val("");
  58.             $(that).find("#Meteorology").fadeOut();
  59.             $(that).find("#Temperature").fadeOut();
  60.         }
  61.     }
  62.  
  63.     function processSelect() {
  64.         var selected = $(".chzn-select option:selected").val();
  65.         /* DELETE APPEND AREA */
  66.         $("li#optional").remove();
  67.         $("li.optional2").remove();
  68.         $("li.optional3").remove();
  69.         /* MAKE SURE ALL INPUT CLEARED */
  70.         $("input").not("input#apikey").not("input#eventinput").not("input#submit").each(function () {
  71.             $(this).val("");
  72.         });
  73.         if (selected == "1" || selected == "2" || selected == "3") {
  74.             $("#errorid").html("105, 106, 107");
  75.             $("#errorh5").show();
  76.         } else if (selected == "4" || selected == "5" || selected == "6") {
  77.             $("#errorid").html("100, 102, 106, 107");
  78.             $("#errorh5").show();
  79.             $("li#last").before('<li id="optional" class="input"><input name="Measure_Value" type="text" placeholder="Measure_Value"></li>');
  80.             $("li#last").before('<li id="optional" class="input"><input name="Measure_Date" type="text" placeholder="Measure_Date"></li>');
  81.             $("li#last").before('<li id="optional" class="input"><input name="Meter_NO" type="text" placeholder="Meter_NO"></li>');
  82.             $("li#last").before('<li id="optional" class="input"><input id="Measure_Mode" name="Measure_Mode" type="text" placeholder="Measure_Mode"></li>');
  83.             $("li#last").before('<li id="optional" class="input"><input name="Char_No" type="text" placeholder="Char_No"></li>');
  84.             $("li#last").before('<li id="optional" class="input"><input name="Operator_NO" type="text" placeholder="Operator_NO"></li>');
  85.             $("li#last").before('<li id="optional" class="input"><input name="Lot_NO" type="text" placeholder="Lot_NO"></li>');
  86.  
  87.             if (selected == "4") {
  88.                 $("li#last").before('<li id="optional" class="input"><input id="event" name="Event" type="text" value="1" placeholder="Event"></li>');
  89.                 $("li#last").before('<li id="optional" class="input"><input name="Blood_Type" type="text" placeholder="Blood_Type"></li>');
  90.             } else if (selected == "5" || selected == "6") {
  91.                 $("li#last").before('<li id="optional" class="input"><input name="QC_Low" type="text" placeholder="QC_Low"></li>');
  92.                 $("li#last").before('<li id="optional" class="input"><input name="QC_High" type="text" placeholder="QC_High"></li>');
  93.                 $("li#last").before('<li id="optional" class="input"><input name="Status" type="text" placeholder="Status"></li>');
  94.             }
  95.  
  96.             if (selected == "6") {
  97.                 $("li#last").before('<li id="optional" class="input"><input name="Strip_Open_Date" type="text" placeholder="Strip_Open_Date"></li>');
  98.                 $("li#last").before('<li id="optional" class="input"><input name="Exception" type="text" placeholder="Exception"></li>');
  99.                 $("li#last").before('<li id="optional" class="input"><input name="Process" type="text" placeholder="Process"></li>');
  100.                 $("li#last").before('<li id="optional" class="input"><input name="Measure_Count" type="text" placeholder="Measure_Count"></li>');
  101.  
  102.             }
  103.  
  104.             /* OPTIONAL */
  105.             $("li#last").before('<li class="optional3" class="input"><input name="IMEI" type="text" placeholder="IMEI"></li>');
  106.             $("li#last").before('<li class="optional3" class="input"><input name="Voltage" type="text" placeholder="Voltage"></li>');
  107.             $("li#last").before('<li class="optional3" class="input"><input name="Temperature" type="text" placeholder="Temperature"></li>');
  108.             $("li#last").before('<li class="optional3" class="input"><input name="People_ID" type="text" placeholder="People_ID"></li>');
  109.             $("li#last").before('<li class="optional2" style="display:none;" class="input"><input name="Customer_DB" type="text" placeholder="Customer_DB"></li>');
  110.             $("li#last").before('<li class="optional2" style="display:none;" class="input"><input name="Phone_Number" type="text" placeholder="Phone_Number"></li>');
  111.             if (selected == "5" || selected == "6") {
  112.                 $("li#last").before('<li class="optional2" style="display:none;" class="input"><input id="event" name="Event" type="text" value="1" placeholder="Event"></li>');
  113.                 $("input#event").val(1);
  114.                 $("input#event").attr("value", 1);
  115.             }
  116.  
  117.             /* blood sugar measurement data SPECIFIC FIELDS */
  118.  
  119.             $("#eventdiv").find("#Measure_Mode").keyup(function () {
  120.                 var that = $(this).closest("#eventdiv");
  121.                 Measure_Mode(that);
  122.             });
  123.             $("#eventdiv").find("#Measure_Mode").change(function () {
  124.                 var that = $(this).closest("#eventdiv");
  125.                 Measure_Mode(that);
  126.             });
  127.         }
  128.  
  129.         $("#eventinput").val(selected);
  130.         $("#eventinput").attr("value", selected);
  131.         $("#eventid").html(selected)
  132.     }
  133.  
  134. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement