Creating a Form Help

I am brand new to this forum and am hoping someone can find it in their heart to help me. To be completely honest, I have never used Javascript but I am familiar with code logic. I just don’t have the time to teach myself in order to do something that I believe will be very simple and take a semi-experienced person 5 minutes to do.

I have made a very simple excel sheet that does everything I would need to form to do. The forum won’t let me upload it so if you have any other suggestions that would be great. All the code i need is to pick one of three word options from a dropdown and do a simple calculation from another cell.


Hi there sandrosferrazzabnw,

and a warm welcome to these forums. :biggrin:

You could try putting it in a zip file and then uploading it. :winky:


I don’t think it’s the file format which is an issue.

@sandrosferrazzabnw is a new member, and needs to reach Trust Level 1 to be able to post attachments.

1 Like

I don’t think it’s the file format which is an issue…

In light of that information, you could try uploading your file to
a suitable repository from which it may be safely downloaded. :biggrin:


@coothead What would be best? @TechnoBear was right i cant upload anything just yet.

I want to have three cells. one for “Length”, one for “Weight”, and a “unit price”
The next cell would have a dropdown menu to choose which unit is being used for pricing (per pound, per foot)
the next cell would simply be a total. for example a supplier would type in…

QTY      Length(ft)      Weight       unit price          UOM(dropdown)              Total
2                20                n/a              3.5                    Per foot               3.5 * 20 * 2 = 140

I hope the above formats the way i just typed it lol. If the supplier prices material by weight then they would input the weight, leave the length cell empty, and choose per pound in the drop down.
The only thing i require is the code to go into the Total cell because it would need to read something like this…
If (dropdown) = per pound Then
total = (unit price) x (weight)
Else if (dropdown) = per foot Then
total = (unit price) x (length)
End if

It really, really helps to describe the requirements clearly yet as concisely as possible. The next step is to figure out how to do each of the necessary things. Then ask about individual things separately. For example a programmer might ask how to read a file and make it a table, but that is at least two questions; reading the file and making a table.

That seems vague to me and seems to be multiple questions.

See the following.

There are other sites where we can upload static code (that does not provide a way to ececute the code) that I have seen but I do not remember specifics. If you are serisous about developing then it is worthwhile to learn Git and GitHub but I am a beginner with that myself.

I believe the formula is incorrect and should be:

total = qty x unit price 

To get the price per length and price per weight you would need something like:

20ft = 3.5 
20ft/20 = 3.5/20 
ft = .175 

thank you for your responses. the formula is correct. i just need a conditional statement in javascript to do the calculation based on whatever is in the dropdown menu.
the dropdown will either be Per foot, Per Pound, or Each.
there will be a corresponding cell for the supplier to input the actual unit price as I showed in the table above. They would then simply choose the applicable unit of measurement (UOM) so the total cell calculates properly. please let me know if there is any other information i can provide

I recommend then that we guide you through the process of doing this simple calculation.

Shall we start with the HTML code that you have for the form?

Based on what you’ve supplied here, I suspect that you have no form. So, I’ll put together a simple, but badly designed solution here for you.

Here’s the simple HTML form:

    <label>Qty <input name="qty"></label>
    <label>Length <input name="len"></label>
    <label>Weight <input name="weight"></label>
    <label>Unit price <input name="unitprice"></label>
        <select name="uom">
            <option value="">Please select</option>
            <option value="pound">per Pound</option>
            <option value="foot">per Foot</option>
    <label>Total <span class="total"></span></label>
    <input type="submit" value="Calculate">

And here’s the simple script:

var uom = document.querySelector("[name=uom]");
uom.addEventListener("change", function (evt) {
  var option =;
  var form =;
  var qty = Number(form.elements.qty.value);
  var weight = Number(form.elements.weight.value);
  var len = Number(form.elements.len.value);
  var unitprice = Number(form.elements.unitprice.value);
  var total = 0;
  if (option.value === "pound") {
    total = unitprice * weight;
  if (option.value === "foot") {
      total = unitprice * len;
  document.querySelector(".total").innerHTML = qty * total;

Hopefully it does just what you need.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.