How to end function early
| 12:38 pm on May 7, 2002 (gmt 0)|
If anyone has a minute to look at this script, could you tell me how to make the function end after an alert. I set the select box description(size and color) as the selected values, but want the function to end if they didn't make a valid choice. I know it would be easy enough to just take that value out of the form, but I know there is a way to do it. Anyway, here it is:
var picksize="Please choose a size."
var pickcolor="Please choose a color."
var desc="Your dress size is " + dsize + ". " + dcolor + " is your color choice. Your final cost for this dress is " + cost + ". And remember shipping is absolutely free!!!";
var sOrder = "https://www.paypal.com/cart/add=1&business=m00n106%40aol.com&item_name=Flower girl dress(" + dcolor + ")(size " + dsize + ")&item_number=fgd88030&amount=" + cost;
| 1:10 pm on May 7, 2002 (gmt 0)|
You can break up this large function into smaller functions. Alert functions and assignment functions. Call the assignment functions if you don't alert.
| 1:27 pm on May 7, 2002 (gmt 0)|
Like Korkus said, I would break it up into smaller functions.
You could create flags (boolean variables) that get set when an alert is given. Then you could check the flag - if false you know that they never had a valid selection.
You also might want to look into the "switch" command instead of the else-if in this case.
With switch you can set a default: which would return false. You can also set "break;" to get out of the routine.
Good luck with it. It sounds like a fun project.
| 2:39 pm on May 7, 2002 (gmt 0)|
>Good luck with it. It sounds like a fun project.
It is fun :) , but time consuming! :o It's my mothers bridal shop site. She hired someone to build it but they only gave her like three pages and no way to even order! :( I got the ftp access and started changing, but didn't realize what I wasw getting into. It'll probably have 400 or more pages, plus, as you can see there are lots of variables in the items. I had just started learning HTML not long before. By the time I finish this site I hopefully have a clue. Anyway thanks again. If, by chance you wanted to check it out, I put it in profile.