473,385 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Javascript getelementbyid multiple elements same id

1
This is actually my school project. I doing a table form and want to loop at Course Marks column and Course Grade Point column. Somehow i'm unable to to figure it out. Need a help to fix my work. Thank in advance.

Expand|Select|Wrap|Line Numbers
  1. <table border="1">
  2. <tr>
  3.     <th>Course Marks</th>
  4.     <th>Course Grade Point</th>
  5.  
  6. </tr>
  7. <tr>
  8.     <td><input type="text" id="Mark1"  onfocusout="myFunction1()"></td>
  9.     <td><input type="text" id="Point1" ></td>
  10.     </tr>
  11.  
  12. <tr>
  13. <td>
  14.     <td><input type="text" id="Mark2" onfocusout="myFunction1()"></td>
  15.     <td><input type="text" id="Point2"  ></td>
  16.     >
Script
Expand|Select|Wrap|Line Numbers
  1. function myFunction1() {
  2. var gradep=0.0;
  3. var x = document.getElementById("Mark1");
  4. var y = document.getElementById("Point1");
  5. y.value = typeof x.value;
  6. va= Number(y.value);
  7. y.value = typeof va;
  8. x= Number(x.value);
  9. if (x>=80 && x<=100){
  10.         gradep=4.00;
  11.         }
  12. else if (x>=75 && x<=79){
  13.         gradep=3.67;
  14.         }
  15. else if (x>=70 && x<=74){
  16.     gradep=3.33;
  17.         }
  18. else if (x>=65 && x<=69){
  19.     gradep=3.00;
  20.         }
  21. else if (x>=60 && x<=64){
  22.     gradep=2.67;
  23.         }
  24. else if (x>=55 && x<=59){
  25.         gradep=2.33;
  26.         }
  27. else if (x>=50 && x<=54){
  28.         gradep=2.00;
  29.         }
  30. else if (x>=45 && x<=49){
  31.         gradep=1.67;
  32.         }
  33. else if (x>=40 && x<=44){
  34.         gradep=1.33;
  35.         }
  36. else if (x>=35 && x<=39){
  37.         gradep=1.00;
  38.         }
  39. else if (x>=0 && x<=34){
  40.     gradep=0.00;
  41.         }
  42. y.value= gradep.toFixed(2);
  43.  
  44.         }
Nov 22 '14 #1
0 1843

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

Similar topics

1
by: Johannes Koch | last post by:
How to remove multiple elements with the same child element content? E.g. input: <root> <foo> <bar>ABC</bar> </foo> <foo> <bar>DEF</bar> </foo>
12
by: Jochen Daum | last post by:
Hi! I have a dynamically generated page (PHP), which contains an Explorer like view of items. I would like to hide multiple <tr>'s by name, but I can't figure out how thats done. I have this...
4
by: itunes66 | last post by:
how can i do this i already have a function to show/hide elements with one link but how can i show/hide multiple elements here is the script function obj_ref(object) { if...
0
by: Carl Howarth | last post by:
Hi, I need to bind data to a datagrid and have a custom hyperlink column that has multiple elements in the querystring: Page.aspx?1=Hello&2=Goodbye... The query string needs to be populated...
1
by: Varun Kacholia | last post by:
I apologize if there exists a standard way of deleting multiple elements from a STL hash_multiset (or even multiset for that matter) that I am unaware of. The problem, I see, with multisets is...
4
by: R | last post by:
Hi All, I have problem with sorting nodes I want sort them by columns c1, c2 also I have node <root><sort ActiveField="c0"/></root> ActiveField attribute is set by user. I'm sorting 'row'...
2
by: libsfan01 | last post by:
hi! i have written a function to make visible elements with a certain id. however i intended it to be used to make visible multiple elements but it only appears to switch on the first element it...
1
by: MORALBAROMETER | last post by:
Hi all, I want to update MULTIPLE elements of an HTML page using Ajax. for this reason i my response is an xml document. I want to use XSL at the client side to update these elements. How can i...
3
Jezternz
by: Jezternz | last post by:
Okay, Basicly I want to style multiple input fields with a new border, background ect. However when I use a class they do not change in FF, when I give them all the same ID they do change in FF. I...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.