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 4013226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:20:42+00:00 2026-05-20T09:20:42+00:00

$(.panel_wager_container input).change(function(event) { var wager = $(this).val(); var multiplier = $(‘#multiplier’).html(); var limit =

  • 0
$(".panel_wager_container input").change(function(event)
{
    var wager = $(this).val();
    var multiplier = $('#multiplier').html();
    var limit = 15.00;
    var winnings = $("#potential_winnings").val();
    if(wager - 0 == wager && wager.length > 0) {
        if(winnings <= limit) {
            $("#potential_winnings").html(Math.round((wager * multiplier) * 100) / 100);
        } else {
            $("#potential_winnings").html = limit;
            $(".panel_wager_container input").html(Math.round((limit / multiplier) * 100) / 100);
        }
    } else {
        $("#potential_winnings").html('0.00');
    }
});

Im not sure why this jquery code is not working. The aim is to take in the input variable and multiple it by the multiplier to work out the winnings. I want to limit the maximum winnings to 15.00. If the winnings is below the limit update #potential_winnings. If the winnings is above the limit set the #potential_winnings to the limit variable and then work out the wager based on the potential_winnings and set that.

I’ve tried to debug this as much as I can, but I cant work out the right way to do it. The lines that dont work seem to be:
var winnings = $(“#potential_winnings”).val();
winnings doesnt ever evaluate as less than limit. If I replace winnings with a variable lower than limit it evaluates correctly.

AND:
$(“.panel_wager_container input”).html(Math.round((limit / multiplier) * 100) / 100);
This line does not output any changes to the selected element.

This is the html this script it working on:

<div class="panel_wager_inform">Maximum Wager: 170.00</div><br /> 
                    <div class="panel_wager_container"> 
                    <img src="/img/rounded/input/left.png" class="left" alt="" /><img src="/img/rounded/input/right.png" class="right" alt="" /><div class="input text required"><label for="BetWager">Wager</label><input name="data[Bet][wager]" type="text" value="170.00" id="BetWager" /></div>                        
                    </div><br /> 
                    <div class="clear"></div> 
                    <strong>Multiplier:</strong> <span id="multiplier">11.85</span>x<br /><br /> 
                    <strong>Potential Winnings:</strong> 
                    $<span id="potential_winnings">2,014.84</span> 

Any help would be greatly appreciated. Thank you.

UPDATED: This was the solution I used after the guidance from this thread. Thank you for the help.

    $(".panel_wager_container input").change(function(event)
{
    var wager = $(this).val();
    var multiplier = $('#multiplier').html();
    var limit = 15.00;
    var winnings = Math.round((wager * multiplier) * 100) / 100;
    if(wager - 0 == wager && wager.length > 0) {
        if(winnings <= limit) {
            $("#potential_winnings").html(Math.round((wager * multiplier) * 100) / 100);
        } else {
            $("#potential_winnings").html(limit);
            $(".panel_wager_container input").val(Math.round((limit / multiplier) * 100) / 100);
        }
    } else {
        $("#potential_winnings").html('0.00');
    }
});
  • 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-20T09:20:43+00:00Added an answer on May 20, 2026 at 9:20 am

    .val() only works for input controls. You need to get the contents with .text():

    var winnings = $("#potential_winnings").text();
    

    Furthermore, you should “cast” the returned String into an Integer by invoking either parseInt() or use +.

    if(+winnings <= limit) {
    }
    

    The same goes for your multiplier variable. Example:

    $(".panel_wager_container input").change(function(event)
    {
        var wager       = +$(this).val(),
            $multiplier = $('#multiplier'),
            $potentialwinnings = $("#potential_winnings"),
            multiplier  = $multiplier.html(),
            limit       = 15.00,
            winnings    = +$("#potential_winnings").text();
    
        if(wager.length > 0) {
            if(winnings <= limit) {
                $potentialwinnings.html(Math.round((wager * multiplier) * 100) / 100);
            } else {
                $potentialwinnings.html = limit;
                $(".panel_wager_container input").html(Math.round((limit / multiplier) * 100) / 100);
            }
        } else {
            $potentialwinnings.html('0.00');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.