From b11480a90c015191adea4734ddcf0ebfee0303bc Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 11 Apr 2018 17:53:57 +0630 Subject: [PATCH] Add Total Customer --- app/views/origami/surveys/_form.html.erb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb index 5640b549..52e8a517 100755 --- a/app/views/origami/surveys/_form.html.erb +++ b/app/views/origami/surveys/_form.html.erb @@ -9,12 +9,12 @@
- <%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10' }%> + <%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10', :onChange => "total_customer();" }%>
- <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10' }%> + <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onChange => "total_customer();" }%>
@@ -30,7 +30,7 @@ - <%= f.input :total_customer, input_html: { value: @survey_data.total_customer, class: 'col-md-11'} %> + <%= f.input :total_customer, input_html: { value:@survey_data.total_customer , :readonly => true, class: 'col-md-11'} %> <%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-11' }%> @@ -457,4 +457,11 @@ var cashier_type = "<%= @cashier_type %>"; }); } } + + function total_customer(){ + var child = $("#survey_child").val() || 0; + var adult = $("#survey_adult").val() || 0; + var result = parseInt(child) + parseInt(adult); + $("#survey_total_customer").val(result); + } \ No newline at end of file