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 6550943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:16:37+00:00 2026-05-25T12:16:37+00:00

I am constructing a simple calculator using a form that requires selections from a

  • 0

I am constructing a simple calculator using a form that requires selections from a drop down which when run inputs 3 different calculations into 3 different fields. Anyway — I have put some js in the code to prevent invalid selection combinations, using an alert to inform the user. What I would like to do is reset only the inputs (changing none of the drop downs when the user clicks “ok” on the alert box. I’m a newbie, tried several things and not come close. Any help?

<script type="text/javascript">
function clearInputs() {
    document.getElementById("RawCapacity").value = "";
    document.getElementById("RAIDCapacity").value = "";
    document.getElementById("WindowsCapacity").value = "";
    }

function RAIDcalc() {
    //Values put into the calculator
    var A = document.forms[0].DriveCapacity.value *1;
    var B = document.forms[0].NumberOfDisks.value *1;
    var C = document.forms[0].RAID.value *1;
    var D = document.forms[0].HotSpare.value *1;

    //Pre-math for the calculations 
    var E = C + D;
    var F = B - E;
    var G = A * 0.95;

    var H = document.getElementById("RAID").options[document.getElementById("RAID").selectedIndex].text

    //Validate form (to ensure selections are made), 
    //validate values (to prevent impossible combinations), 
    //and to calculate and write the responses
    if (A == "null") {
        alert("Please make a selection in the required fields.");
        clearInputs();
        }
    else if (B == "null") {
        alert("Please make a selection in the required fields.");
        clearInputs();
        }
    else if (C == "null") {
        alert("Please make a selection in the required fields.");
        clearInputs();
        }
    else if (H == "RAID 5" && B<=(D + (1 * 1))) {
        alert("This configuration has too many Hot Spares.");
        }
    else if (H == "RAID 6" && B<=(D + (2 * 1))) {
        alert("This configuration has too many Hot Spares.");

    else if (H == "RAID 6" && B<4) {
        alert("RAID 6 requires a minimum of FOUR disks.");
        }
    else {
        document.forms[0].RawCapacity.value = Math.round(((A * B) / 1000)*Math.pow(10,2))/Math.pow(10,2) + " TB";   
        document.forms[0].RAIDCapacity.value = Math.round(((F * A) / 1000)*Math.pow(10,2))/Math.pow(10,2) + " TB";  
        document.forms[0].WindowsCapacity.value = Math.round(((F * G) / 1000)*Math.pow(10,2))/Math.pow(10,2) + " TB";
        }
    //For testing
    //alert("A="+A+" B="+B+" C="+C+" D="+D+" E="+E+" F="+F+" G="+G);
    //var RAIDtext = document.getElementById("RAID");
    //var RAIDselindex = document.getElementById("RAID").selectedIndex;
    //alert (document.getElementById("RAID").options[document.getElementById("RAID").selectedIndex].text);
    //if (H == "RAID 6" && B<4) alert("H = RAID 6 & B<4!");

    }
</script>
  • 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-05-25T12:16:37+00:00Added an answer on May 25, 2026 at 12:16 pm

    Add a function to clear the input fields:

    function clearInputs() {
        document.getElementById("RawCapacity").value = "";
        document.getElementById("RAIDCapacity").value = "";
        // The same for other fields
    }
    

    and call it along with each alert() call:

    if (A == "null") {
        alert("Please make a selection in the required fields.");
        clearInputs();
    }
    

    (Note: the condition in the if should use the == operator, which is used for comparison. = is for assignments.)

    By the way, your else block is missing the curly braces, it should say:

    else {
        document.forms[0].RawCapacity.value = Math.round(((A * B) / 1000)*Math.pow(10,2))/Math.pow(10,2) + " TB";   
        document.forms[0].RAIDCapacity.value = Math.round(((F * A) / 1000)*Math.pow(10,2))/Math.pow(10,2) + " TB";  
        document.forms[0].WindowsCapacity.value = Math.round(((F * G) / 1000)*Math.pow(10,2))/Math.pow(10,2) + " TB";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm constructing a simple search form for our support ticket database using Lucene.Net, and
I'm constructing a simple form in ERB but the HTML produced by the text_field
I am constructing a large HTML document from fragments supplied by users that have
I need help constructing a monitor that implements a semaphore, and simple C example
I've just written (in Perl) a simple web service that displays a web form
I am constructing a simple modified Subtraction-only calculator where z = x - y.
I'm constructing a simple container class but run into some problems (reassembling the ones
We have a simple LOB application that: pulls data from EF serves data across
Given: Constructing an ADO Connection object from one thread and giving it to another
I am having trouble constructing a single XPath statement to return two different sets

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.