JQuery Part 2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.