Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:04:48+00:00 2026-06-14T22:04:48+00:00

this one is driving me nuts so I certainly hope the SO community can

  • 0

this one is driving me nuts so I certainly hope the SO community can shed some light on this for me. The problem is that I am creating an order form where the user has two options to select from (reports or ratings) which dynamically populate a quantity drop down. In order to calculate the total of their orders I believe I have to turn the drop downs into arrays, however I have no idea how to do this for the dynamic drop down. To clarify the array is supposed to associate a monetary value to every option. Here is some code:

Javascript for dynamic options:

     function dropdownlist(listindex)
      {
       document.form.rnr.options.length = 0;

      switch (listindex)
     {

     case "0" :
          document.form.rnr.options[0]=new Option("1 - $40","1");
          document.form.rnr.options[1]=new Option("10 - $350 ($35 ea)","10");
          document.form.rnr.options[2]=new Option("25 - $700 ($28 ea)","25");
          document.form.rnr.options[3]=new Option("50 - $1200 ($24 ea)","50");
          document.form.rnr.options[4]=new Option("100 - $2000 ($20 ea)","100");
     break;

     case "1" :
          document.form.rnr.options[0]=new Option("Up to 249 - $750 (~$3 ea.)","249");
          document.form.rnr.options[1]=new Option("Up to 499  - $1375 (~$2.75 ea.)","499");
          document.form.rnr.options[2]=new Option("Up to 1000 - $2500 (~$2.50 ea)","1000");
          document.form.rnr.options[3]=new Option("1000+ - $4000","100000");

     break;

        }
     return true;
     }

And the example code that I found online of what I am trying to do as far as arrays is this:

     var cake_prices = new Array();
     cake_prices["Round6"]=20;
     cake_prices["Round8"]=25;
     cake_prices["Round10"]=35;
     cake_prices["Round12"]=75;

Please ignore the fact the example uses cakes, a cake order form was the example used by the developer for the tutorial I am using, unfortunately the tutorial is for static data. Thanks in advance, and if any clarification is needed or any additional code is required feel free to let me know!

ADDITION:

Dropdown is called in the form like this:

     <select class="form" name="type" id="type" style="height:26px;" onchange="javascript:dropdownlist(this.options[this.selectedIndex].value);"> 
     <option value="" selected="selected" disabled="disabled">Select an Option</option>
     <option value="0">Reports</option>
     <option value="1">Ratings</option>

    <script type="text/javascript" language="JavaScript">
    document.write('<select class="form" name="rnr" id="rnr" style="height:26px;"><option value="">Select an option</option></select>')
    </script>
    <noscript>
    <select class="form" name="rnr" id="rnr" style="height:22px; "></select>
    </noscript>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:04:49+00:00Added an answer on June 14, 2026 at 10:04 pm

    Ok, I figured this one out on my own and here is what I did for anyone that faces this problem themselves:

        <script>
         var rnr_prices= new Array();
             rnr_prices["1"]=40;
             rnr_prices["10"]=350;
             rnr_prices["25"]=700;
             rnr_prices["50"]=1200;
             rnr_prices["100"]=2000;
             rnr_prices["249"]=750;
             rnr_prices["499"]=1350;
             rnr_prices["249"]=750;
             rnr_prices["1000"]=2000;
             rnr_prices["100000"]=4000;
    
         function getDropPrice()
         {
            var dropPrices=0;
            var theForm = document.forms["form"];
            var selectedtype = theForm.elements["rnr"];
    
            dropPrices = rnr_prices[selectedtype.value];
    
            return dropPrices;
         }
       </script>
    

    The solution was found here: http://www.javascript-coder.com/javascript-form/javascript-calculator-script.phtml

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if anyone can shed some light on an issue that is driving
I'm driving myself nuts with this particular problem, i really hope someone can help!
This one has been driving me nuts. I have a div that has it's
This is a dumb newbie question, but one that is driving me nuts. I
This one is driving me nuts. The problem occurs in a two-server-system, where server
OK, this one is driving me nuts.... I have a string that is formed
Ok, this one is driving me nuts. I have a backend file uploader that
This is driving me nuts! A little piece of code that I can't seem
This one's got me stumped and it's driving me nuts. I have a SiteFinity
No luck at MSDN with this one, which is driving me nuts. I us

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.