Guest User

Untitled

a guest
Aug 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. function calc(ppForm) {
  2. //Get the selected option
  3. var option_price = ppForm.os0.options[ppForm.os0.selectedIndex];
  4. //Get the <input name="amount"
  5. var amount = ppForm.amount;
  6. //Set amount value to the selected option value
  7. amount.value = option_price.value;
  8. //Get item_name
  9. var itemname = ppForm.item_name;
  10. //Get selected option innerHTML
  11. var selected_option = ppForm.os0.options[ppForm.os0.selectedIndex].innerHTML;
  12. //loop through options in select menu
  13. for (i=0; i <= ppForm.os0.options.length - 1; i++) {
  14. //Check if the function has been called already by checking if
  15. //the options innerHTML has been concatenated onto the itemname
  16. //value
  17. if (itemname.value.indexOf(ppForm.os0.options[i].innerHTML) > -1) {
  18. //We matched the innerHTML in the itemname value.
  19. //Get the length we need to chop off for the substr
  20. var chop = parseInt(itemname.value.length - ppForm.os0.options[i].innerHTML.length);
  21. //Remove the innerHTML form the previous function call
  22. //by substringing it
  23. itemname.value = itemname.value.substr(0, chop);
  24. }
  25. }
  26. //Concatenate the selected option innerHTML onto the itemname value
  27. itemname.value += ' ' + ppForm.os0.options[ppForm.os0.selectedIndex].innerHTML;
  28. }
Add Comment
Please, Sign In to add comment