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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:03:14+00:00 2026-05-30T14:03:14+00:00

I have a page whereby the user can press left + right buttons to

  • 0

I have a page whereby the user can press left + right buttons to scroll through numbers between 1-10.

The default value is 0 which displays blank.

There are two buttons at the bottom which allow the user to ‘Clear’ the number – reseting it to 0. Or to ‘Shuffle’, picking a random number.

After this the user can submit these numbers into a database.

My issue is, if the user were to scroll to 5 (for example), click shuffle then submit, it would submit ‘5’ instead of the random number it should have generated.

Also if the user only clicks ‘shuffle’ then submit, it’ll input ‘0’.

The issue with the ‘clear’ button is similar, if the user scrolls to 5, then hits reset, the variable would stay at ‘5’ when submitted.

I’m probably overcomplicating something very simple, and im sorry if i am, but this is annoying me.

Thankyou ~

  • 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-30T14:03:16+00:00Added an answer on May 30, 2026 at 2:03 pm

    I’m not entirely certain what the problem is without looking at your code. I get the feeling it is something like this:

    Javascript

    var opNumb = 0; //default number
    
    left = function(){if (opNumb>0) opNumb--;
                          updateNumb(opNumb);}
    right = function(){if (opNumb<10) opNumb++;
                          updateNumb(opNumb);}
    
    def = function(){opNumb=0;
                     updateNumb(opNumb);} //function to return to default
    
    randomNumb = function(){opNumb = Math.floor(Math.random() * 11);
                            updateNumb(opNumb);} 
    
    updateNumb = function(Numb){document.forms[0].opVal.value = Numb;}
    window.onkeydown = press;            //bind keydown to press function
    
    function press(e){
    if (e.keyCode == 37) left(); 
    if (e.keyCode == 39) right() 
        }
    

    HTML form

    <form id="frm1">
    <input type="text" name="opVal" value="0"/><br />
    <input type="button" value="left" onclick="left()"/><input type="button" value="right" onclick="right()"/><input type="button" value="Clear" onclick="def()"/><input type="button" value="Shuffle" onclick="randomNumb()"/><br />
    <input type="button" value="Submit form" onclick="alert(opNumb);"/>
    </form>​
    

    What does your form look like? You’re most likely having a problem setting a value?

    Link to example

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

Sidebar

Related Questions

I have made an interface whereby the user can create his own form. I've
I have an input page in my C# application whereby my boss can enter
I have a page that the user can modify. All modifications are performed using
I have an action on a page whereby a user clicks to remove a
I have used fieldset tag in HTML page, whereby i need some text to
I have page where I use model which can have different types (depending by
I have page which is redirected from htaccess. now I can pass the German
I have page, i can contact directly without any problems. http://www.mysite.com/app_dev.php/comments/22 the page shows
I have a search box on my site, whereby the user enters a term
iPhone Safari seems to have some sort of problem whereby a page with css

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.