1. HTML and JS transfer values
Html:
@ (lang:string, Shop:shop, Meal:meal, table:diningtable)
@layout ("Dashboard", seq ("/assets/javascripts/operator-dashboard.min.js"), seq ("/assets/stylesheets/ Operator-dashboard.min.css ")) {
<script>
Window.id = @meal. ID;
</script>
Note that the value passed in in HTML requires an @ value and cannot be passed directly to the object and used, such as meal, because the object is only a specific string, but it can be used separately.
Javascript:
id = window.id
You can pass values directly with window
2. js real-time detection input changes, the following input subtotal discount, total real-time changes
Subtotal:
Discount:
Total: $0.00
Displayinvoice = (subtotal, discount)
Discountamount = subtotal*discount/100
$ ('. Display-discount '). html "$" + discountamount.tofixed (2)
Total = 0
Total = Subtotal
Total-= Discountamount
$ ('. Display-total '). html "$" + total.tofixed (2)
Updateinfo= ()
Subtotal = parsefloat ($ (' #subtotal '). Val ())
Discount = parsefloat ($ (' #discount '). Val ())
If!subtotal
Subtotal = 0
If!discount
Discount = 0
Displayinvoice (Subtotal,discount)
$ (document). Ready
$ ('. Btn-pay '). On (' click ',
Paymeal (window.id)
)
$ (' #subtotal '). On (' KeyUp ',
UpdateInfo ()
)
$ (' #discount '). On (' KeyUp ',
UpdateInfo ()
)
$ ('. Input-gst '). On (' click ',
UpdateInfo ()
)
JQuery Part 2