473,513 Members | 4,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I have a problem with writing a script to sum the number inputs of my table

2 New Member
I am very new to java script and i have a table that for the life of me i cannot get to sum. Can anyone help me?
Oct 3 '16 #1
1 1081
F4RR3LL
2 New Member
Expand|Select|Wrap|Line Numbers
  1. <table id="myTable">
  2. <tr>
  3.     <th>Activity</th>
  4.     <th>Sun</th>
  5.     <th>Mon</th>
  6.     <th>Tues</th>
  7.     <th>Wed</th>
  8.     <th>Thur</th>
  9.     <th>Fri</th>
  10.     <th>Sat</th>
  11.     <th>Total</th>
  12.   </tr>
  13. <tr>
  14.   <td>
  15. <select>
  16.   <option>Job Description</option>
  17.   <option>Programing</option>
  18.   <option>Analysis</option>
  19.   <option>Techicnal Writing</option>
  20.   <option>Other</option>
  21.   </select>
  22. </td>
  23. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  24. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  25. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  26. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  27. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  28. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  29. <td align="center" width="5%"><input type="number" value="0" min="1" max="10"></td>
  30. <td align="center" width="5%"><input align="center" type="number" name="total" min="0" max="99999999"></td>
  31. </tr> 
  32. </table>
  33. <button onclick="addRow()">Add Job Description  +</button>
  34. <br>
  35. <br>
  36. <br>
  37. <br>
  38. <br>
  39. <br>
  40.  
  41. <button onclick="myFunction()">Submit</button>
  42.  
  43. <script>
  44. function addRow() {
  45.     var table = document.getElementById("myTable");
  46.     var row = table.insertRow();
  47.     var cell1 = row.insertCell(0);
  48.     var element1 = document.createElement("Select");
  49.     var option1 = document.createElement("option");
  50.     option1.value="1";
  51.     option1.innerHTML="Job Description";
  52.     element1.appendChild(option1);
  53.     var option2 = document.createElement("option");
  54.     option2.value="2";
  55.     option2.innerHTML="Programming";               
  56.     element1.appendChild(option2);
  57.     var option3 = document.createElement("option");
  58.     option3.value="3";
  59.     option3.innerHTML="Analysis";               
  60.     element1.appendChild(option3);
  61.     var option4 = document.createElement("option");
  62.     option4.value="4";
  63.     option4.innerHTML="Technical Writing";               
  64.     element1.appendChild(option4);
  65.     var option5 = document.createElement("option");
  66.     option5.value="5";
  67.     option5.innerHTML="Other";               
  68.     element1.appendChild(option5);
  69. cell1.appendChild(element1);   
  70.     var cell2 = row.insertCell(1);
  71.     var cell3 = row.insertCell(2);
  72.     var cell4 = row.insertCell(3);
  73.     var cell5 = row.insertCell(4);
  74. var cell6 = row.insertCell(5);
  75. var cell7 = row.insertCell(6);
  76. var cell8 = row.insertCell(7);
  77. var cell9 = row.insertCell(8);
  78.  
  79.  
  80.     cell2.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  81.     cell3.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  82.     cell4.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  83.     cell5.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  84.     cell6.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  85.     cell7.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  86.     cell8.innerHTML = "<div align=\"center\"><input type=\"number\" value=\"0\" min=\"1\" max=\"10\"></div>";
  87.     cell9.innerHTML = "<div align=\"center\"><input type=\"number\" name=\"total\" min=\"0\" max=\"99999999\"></div>";
  88. }
  89. </script>
  90.  
Oct 3 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1547
by: news | last post by:
I have no idea if this is a Linux issue or PHP. Looking for clues here. I have a PHP script which I use to upload a CSV spreadsheet into a mySQL database. (The script follows here in a sec.) I was using WindowsXP and MS Excel to take these sheets, edit it if needed, and save it in text based CSV. Then use the PHP script to upload it and...
1
4793
by: Allen | last post by:
I am trying to add an additional photo/hyperlink to the company web site (I didn't create it) without any luck. The mouseover feature 'highlights' pics by swapping them with another pic using this command in some type of array. I added the mailbox in the lower left corner (see link below)http://www.aamechanical.com/indextemp.htm but I...
3
2853
by: Markus Fischer | last post by:
Hi, I'm experiencing a wierd problem with IE 6 in Windows with two _slightly_ different Version. Give the following HTMl-Code, ideally the output of offsetTop should be "105"; a few pixel plus minus would still be ok, whyever. I've tested this successfully on 6.0.2800.1106 on a german W2KPro machine, also with 6.0.2800.1106 on a german...
5
1451
by: mxa | last post by:
Hi, given table : <table id='t1'> <tr><td> data1</td><td>data2</td></tr> </table> i would like to write a function to write and change data2 ( location is fixed ). function changeme () {
14
9741
by: John T Ingato | last post by:
I have a contacts table with name address and such but are missing all phone numbers in the phone number fields. I have just received an updated customer list in Excel and have imported into a new table. Can I run a query that will take the phone number only from the new table and update the old tables phone number fields from empty to the...
9
2372
by: Jerim79 | last post by:
Here it is: <?php if($_SERVER=='POST'){ $Number=$_POST; $Email=$_POST; $Number2=0; $error=0;
2
4849
by: M Bourgon | last post by:
I'm trying to automate an auto-export of a table on a daily basis, using BCP. I'm using native format for the BCP because the text in one of the fields can encompass pretty much any ASCII characters, and using the other options (including the null terminator, stuff like |||, etc) hasn't worked particularly well. So, I'm archiving out a...
3
1553
by: Ciara9 | last post by:
I am using Access 2003 and have 2 tables. One has customer information in it (such as name,dates,amount, etc...) and the 2nd table is more of a Comments table (displays username, time and date, and the actual comments) about the customer account. I would like to have one form that gathers all this information; however, I would like it to write...
7
19492
by: abhishekitb | last post by:
Hello, I need to get partition script for a table. As we get create table script , i need a table's Partition script. please help me with your expertise.
3
1275
by: troy_lee | last post by:
I have a linked table (two primary keys: one coming from Me.txtRMA# and the other is an Autonumber) that I am writing to from an unbound form. Please review my code and tell me what is wrong with it. I don't get any errors and no data is written to the table. It doesn't do anything. Thanks for the help Private Sub cmdSubmit_Click() On...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7125
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.