diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb
index e480430f..8c2b895e 100755
--- a/app/views/origami/surveys/_form.html.erb
+++ b/app/views/origami/surveys/_form.html.erb
@@ -14,7 +14,7 @@
- <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onChange => "total_customer();" }%>
+ <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onkeyup => "total_customer();" }%>
@@ -332,10 +332,34 @@ var cashier_type = "<%= @cashier_type %>";
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
- $('.addfocus').val(input_value);
+ var value = $('.addfocus').val(input_value);
+ if ($("#survey_child").hasClass('addfocus')){
+ var child = $("#survey_child").val()+value;
+ var adult = $("#survey_adult").val() || 0;
+ var result = parseInt(child) + parseInt(adult);
+ $("#survey_total_customer").val(result);
+ }
+ if ($("#survey_adult").hasClass('addfocus')){
+ var adult = $("#survey_adult").val()+value;
+ var child = $("#survey_child").val() || 0;
+ var result = parseInt(child) + parseInt(adult);
+ $("#survey_total_customer").val(result);
+ }
}
else{
- $('.addfocus').val(original_value + '' + input_value);
+ var value = $('.addfocus').val(original_value + '' + input_value);
+ if ($("#survey_child").hasClass('addfocus')){
+ var child = $("#survey_child").val()+value;
+ var adult = $("#survey_adult").val() || 0;
+ var result = parseInt(child) + parseInt(adult);
+ $("#survey_total_customer").val(result);
+ }
+ if ($("#survey_adult").hasClass('addfocus')){
+ var adult = $("#survey_adult").val()+value;
+ var child = $("#survey_child").val() || 0;
+ var result = parseInt(child) + parseInt(adult);
+ $("#survey_total_customer").val(result);
+ }
}
break;
@@ -351,7 +375,18 @@ var cashier_type = "<%= @cashier_type %>";
break;
case 'clr':
- $('.addfocus').val("");
+ $('.addfocus').val("");
+ if($("#survey_child").hasClass('addfocus')){
+ $("#survey_child").val("");
+ var adult = $("#survey_adult").val() || 0;
+ var result = parseInt(adult);
+ $("#survey_total_customer").val(result);
+ }else if($("#survey_adult").hasClass('addfocus')){
+ $("#survey_adult").val("");
+ var child = $("#survey_child").val() || 0;
+ var result = parseInt(child);
+ $("#survey_total_customer").val(result);
+ }
break;
}
event.handled = true;
@@ -464,4 +499,6 @@ var cashier_type = "<%= @cashier_type %>";
var result = parseInt(child) + parseInt(adult);
$("#survey_total_customer").val(result);
}
+
+
\ No newline at end of file