scripts.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // File Name: scrips.js
  2. // Author Name: In-young Choung
  3. // Date: March 1, 2017
  4. // Description: This Javascript file redirects users' input values asynchronously
  5. // to the end points in python file.
  6. /**
  7. * handling form data passed from html and relaying it to python
  8. *
  9. * @param itemtype
  10. * @param brandN1
  11. * @param brandN2
  12. * @param price1
  13. * @param price2
  14. * @param weight1
  15. * @param weightT1
  16. * @param weight2
  17. * @param weightT2
  18. * @param discount1
  19. * @param discountT1
  20. * @param discount2
  21. * @param discountT2
  22. */
  23. function calc_handle(itemtype, brandN1, brandN2, price1, price2,
  24. weight1, weightT1, weight2, weightT2,
  25. discount1, discountT1, discount2, discountT2) {
  26. // create an object of XMLHttpRequest
  27. x = new XMLHttpRequest();
  28. // send an http request to /calculate which is mapped in python
  29. x.open("GET", '/calculate?param1=' + itemtype + '&param2=' + brandN1 + '&param3=' + brandN2 +
  30. '&param4=' + price1 + '&param5=' + price2 + '&param6=' + weight1 + '&param7=' + weightT1 +
  31. '&param8=' + weight2 + '&param9=' + weightT2 + '&param10=' + discount1 + '&param11=' + discountT1 +
  32. '&param12=' + discount2 + '&param13=' + discountT2);
  33. // fire the request
  34. x.send();
  35. }