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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:00:08+00:00 2026-05-26T18:00:08+00:00

I’m having a period mental melt down here. For 2 days, I’ve been looking

  • 0

I’m having a period mental melt down here. For 2 days, I’ve been looking at numbers and trying to get this damn calculation to work, but now i can’t get the result method to work.

I’m having 1 textboxs, 2 checkboxs, 1 dropdown and a h1 where the result will be shown.

What i need help with is the calculation and the showing of the result.
Heres the JQuery code I’m having.

    var iAlt = 0;

    // DROPDOWN
    var halloAbo = "";
    $('#hallo-abo').change(function (){
        halloAbo = $('#hallo-abo').val();   
            //$('#sk').text(halloAbo);
    });


    // TEXTBOX
    var maxregning = 0;
    $('#maxRegning').focusout(function(){
        maxregning = 0;
        maxregning = $('#maxRegning').val();

        $('#sk').text(maxregning);
    });



    // SELECT 1
    var pakkerTotal = 0;
    $('#pakker :checkbox').click(function() {
        pakkerTotal = 0;
        $('#pakker :checkbox:checked').each(function(idx, elm) {
            pakkerTotal += parseInt(elm.value, 10);
        });
        //visResultat();
    });

    // SELECT 2
    var betalTotal = 0;
    $('#betal :checkbox').click(function() {
        betalTotal = 0;
        $('#betal :checkbox:checked').each(function(idx, elm) {
            betalTotal += parseInt(elm.value, 10);
        });
        //visResultat();

    });

    // NEED HELP HERE
    var buffer1 = 0;
    var buffer2 = 0;
    function visResultat(){
        iAlt = eval(maxregning -= pakkerTotal -= betalTotal);
        $('#sk').text(iAlt)
    }


    //$('#sk').text(iAlt);

Heres some of the HTML

// DROPDOWN    
<select id="hallo-abo" style="float:left;">
<option value="">Vælg dit abo</option>
<option value="49">test 1</option>
<option value="99">test 2</option>
ect
</select>

// TEXTBOX
<input type="textbox" id="maxRegning" value="" />


// CHECKBOX 1
<div id="pakker">
<input type="checkbox" value="39" />test 1<br/>
<input type="checkbox" value="79" />test 2<br/>
</div>

//CHECKBOX 2
<div id="betal">
<input type="checkbox" value="6,5" />test 1<br/>
<input type="checkbox" value="36" />test 2
</div>

// RESULT
<h1 id="sk">0</h1>

Hope some one can help me here

  • 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-26T18:00:09+00:00Added an answer on May 26, 2026 at 6:00 pm

    This looks very wrong;

    iAlt = eval(maxregning -= pakkerTotal -= betalTotal);
    

    I suspect you just wanted:

    iAlt = maxregning - pakkerTotal - betalTotal;
    

    First point: The -= operator actually changes the value on the left, rather than just returning the result of the calculation. So what you line was doing was actually changing maxregning and pakkerTotal.

    Second: You were doing some arithmetic, and then “eval”ing the result. This is meaningless; if the maths came out to 12, it would eval 12.toString(), which is “12”. eval(“12”) is 12.

    Thirdly: Eval is almost always the wrong answer 😉 If you think you need to eval() anything, stop and think about it, and then don’t do it.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.