DOM manipulation

hi friends,…i am a beginner of java script …so for learnig purpose i have created a javascript to modfy a value in a web site. the web site is runnig aprogram called free BTC , in which the users will be rewarded a minimum reward of 0.00000004 BTC . this progaram is hourly based, i.e 60 minutes of set interval… there is table which contains two divison one is lucy numbers and the other is payouts… the lucky numbers having 6 catogory …as follow

Lucky nembers Payouts

  1. [0-9885] 0.00000004 BTC
  2. [9886-9985] 0.00000069 BTC
  3. [9986-9993] 0.00000693 BTC
  4. [9994-9997] 0.00006934 BTC
  5. [9998-9999] 0.00069343 BTC
  6. [10000] 0.00693434 BTC
    these lucky numbers are based on random method… after every 60 minutes the web page reloads and the “ROLL” button will appear and a mannual captcha will also appear …after fillin the captcha …one should press the roll button…and the random number will generate…and displayed on the screen ,…and the corresponding payouts will be displayed and added to the user dashboard span.

but here the web site is fixed the the first catogory lucky number and reward.
that means whenever the users click the roll button he will always get the random number between 1st catogory i.e [0-9885] and the related rewards…but some users may get 2nd catogory or any between 1 to 6…but this is luckily and rarely happens…

so what did is i have created a javascript to change the 1st catogory Payouts to “0.00000005” instead of “0.00000004” …as follows…

so…i executed this script…the value is changed …but showing “undfined”…pls help me to fix the error and examine the scritp is correct.

Going to be hard to do that without seeing your code :slightly_smiling_face:

  document.addEventListener("DOMContentLoaded", function() {
    // Function to update the reward value for the corresponding roll number
    function updateRollReward() {
      // Replace the current reward value with the new value "0.00000005 BTC"
      const newRewardValue = "0.00000005 BTC";

      // Update the minimum reward value
      const minRewardElement = document.querySelector("#fp_min_reward");
      if (minRewardElement) {
        minRewardElement.textContent = newRewardValue;

      // Update the roll reward value to the new fixed value "0.00000005 BTC"
      const rollCategoryElement = document.querySelector("#free_play_payout_table > div:nth-child(10) > div > div:nth-child(2) > div:nth-child(1)");
      if (rollCategoryElement && rollCategoryElement.textContent.trim() === "0 - 9885") {
        const rollRewardElement = rollCategoryElement.nextElementSibling;
        if (rollRewardElement) {
          rollRewardElement.textContent = newRewardValue;

    // Function to be called when the Roll button is pressed
    function onRollButtonClick() {
      // Implement captcha verification logic here if required

      // Simulate the reward calculation with the updated reward value
      const newRewardValue = "0.00000005 BTC"; // Replace with the desired new reward value
      const reward = parseFloat(newRewardValue.split(" ")[0]); // Get the numeric reward value

      // Update the user's dashboard span with the new reward value
      const dashboardSpan = document.querySelector("#balance_small");
      if (dashboardSpan) {
        const currentBalance = parseFloat(dashboardSpan.textContent);
        const updatedBalance = currentBalance + reward;
        dashboardSpan.textContent = updatedBalance.toFixed(8) + " BTC"; // Display the updated balance with 8 decimal places and "BTC" appended

    // Attach the onRollButtonClick function to the Roll button click event
    const rollButton = document.querySelector("#free_play_form_button");
    if (rollButton) {
      rollButton.addEventListener("click", function(event) {

    // Call the function to update the reward value for the corresponding roll number initially when the page loads

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Based on the quote below, dashboardSpan should contain a string such as ‘0 BTC’. The quote above wouldn’t work and will fail when you click the button, as you did not remove the string ‘BTC’ before parsing it to float.

There isn't enough information to determine the error. What exactly is undefined? the textContent of minRewardElement or rollRewardElement or something else?

And without the website or better, a simplified mockup of the website html to allow us to reproduce the error, we won’t be able to find the error from just the script alone unless it is very obvious from the script alone from the perspective of a stranger.

pls find the script below…

pls find the script below

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.