Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calc(ppForm) {
- //Get the selected option
- var option_price = ppForm.os0.options[ppForm.os0.selectedIndex];
- //Get the <input name="amount"
- var amount = ppForm.amount;
- //Set amount value to the selected option value
- amount.value = option_price.value;
- //Get item_name
- var itemname = ppForm.item_name;
- //Get selected option innerHTML
- var selected_option = ppForm.os0.options[ppForm.os0.selectedIndex].innerHTML;
- //loop through options in select menu
- for (i=0; i <= ppForm.os0.options.length - 1; i++) {
- //Check if the function has been called already by checking if
- //the options innerHTML has been concatenated onto the itemname
- //value
- if (itemname.value.indexOf(ppForm.os0.options[i].innerHTML) > -1) {
- //We matched the innerHTML in the itemname value.
- //Get the length we need to chop off for the substr
- var chop = parseInt(itemname.value.length - ppForm.os0.options[i].innerHTML.length);
- //Remove the innerHTML form the previous function call
- //by substringing it
- itemname.value = itemname.value.substr(0, chop);
- }
- }
- //Concatenate the selected option innerHTML onto the itemname value
- itemname.value += ' ' + ppForm.os0.options[ppForm.os0.selectedIndex].innerHTML;
- }
Add Comment
Please, Sign In to add comment