473,512 Members | 14,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript getelementbyid multiple elements same id

1 New Member
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 1859

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

Similar topics

1
3916
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
11915
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
8709
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
362
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
2009
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
1447
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
1770
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
3232
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
5486
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
7254
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,...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
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...
1
7094
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...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
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...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
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...

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.