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

  • Home
  • SEARCH
  • 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 6228709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:26:10+00:00 2026-05-24T09:26:10+00:00

Roughly, this is my code: <form name=mpform id=mpform> <input type=checkbox onclick=mpfunc() id=mpay name=mpay[] value=19

  • 0

Roughly, this is my code:

<form name="mpform" id="mpform">
<input type="checkbox" onclick="mpfunc()" id="mpay" name="mpay[]" value="19" style="float:left;" />
//many of the above input tag - only the value changes with other numbers
</form>
<script type="text/javascript">
function mpfunc()
{
var comp=0;
document.getElementById("mpaydiv").style.visibility="visible";
for(var i=0; i< document.getElementById("mpform").elements['mpay[]'].length;i++){
if(document.getElementById("mpform").elements['mpay[]'][i].checked)
comp = comp + document.getElementById("mpform").elements['mpay[]'][i].value;
}
document.getElementById("mpaydiv").innerHTML=comp;
}
</script>
<div id="mpaydiv" style="position:fixed; right:0; visibility:hidden; bottom:0; border:1px solid black; background-color:white; padding:2px 2px;"></div></div>
    </div>

    <div id="footer"></div>
</div>

I have tried substituting getElementById(“mpform”) with form[0],mpform and others but I cant seem to access the values. With the current getelementid I get

Error: document.getElementById(“mpform”) is null Source File:
index.php?page=fakturi Line: 3938

With mpform I get mpform is undefined as with form[0]
Please help. How do I get the sum of the values of all selected checkboxes?

  • 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-24T09:26:11+00:00Added an answer on May 24, 2026 at 9:26 am

    I seem to recall IE having issues with the 0 index of the forms array. You can access it through, document.getElementsByName("mpform")[0] or document.forms['mpform']. To get the checkbox descendants, you might use getElementById('mpay') or document.getElementsByName("mpay")[0] or document.getElementsByName("mpform")[0].elements[0]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
OK so I'm looking a some code which looks roughly like this: void DoSomething(object
I've got HTML code that roughly looks like this: <li id=someid-11> <img src=... alt=alt
I have roughly the following code. Could this be made nicer or more efficient?
A GWT tree looks roughly like this: <div class=gwt-Tree> <div style=padding-top: 3px; padding-right: 3px;
I have a structure that roughly looks like this: List<ProductLine> -> ID Name ...
The codebase at work contains some code that looks roughly like this: #define DATA_LENGTH
I am modifying a bit of C code, that goes roughly like this: typedef
I have some code that roughly does this inside of a GAE worker task:
This code causes my f4v file to stop playing prematurely. Time changes but roughly

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.