Hello users of Coding Forums,

I am building a webstore using Shopsite and am trying to get my custom product options to spit out an updating price based on the selected options from drop-down menus. I know this sounds easy and normally you would just create arrays based on the options, etc. but with Shopsite integration that isn't possible. Instead you have to use the raw streaming data that comes from Shopsite which is listed as [-- PRODUCT.OptionFiniteText --] in the site templates and parse this data with Javascript to somehow create arrays that allow you to do real-time calculations. I am completely stumped on how to do this.

I have a javascript file that was written for me by an engineer at shopsite (as a favor from someone there who is helping me) that parsed the data to change the way the drop-down menu options look.
The code looks like this:
function makeOptions(optList, prodID){
  var options = decodeURIComponent(optList).split('\n');
  var count = 1;
  var optid = 0;
  for (i in options) {
    opt = options[i];
    if (count == 1)   {
      opt = opt.replace(/;n$/, '');
      document.write('<div class="selectoptid'+optid+'">'+opt+' ');
      document.write('<select name="'+prodID+':finopt:'+optid+'" size="1">\n');
    else if (opt == ""){
      count = 0;
    else {
      document.write('<option value="' + opt);
      if (count == 2) {
        document.write('" selected>');
      } else {
  document.write('<input type="hidden" name="'+prodID+':finoptnum" value="'+optid+'">');
However I am a noob at Javascript and don't really understand what this code is doing and how to make a similar code that would instead do real-time calculations by creating arrays.

Sorry if this seems a bit too complex. I would really appreciate any help with this. Thanks