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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:38:35+00:00 2026-05-18T01:38:35+00:00

I asked this question a bit earlier and have only been able to gain

  • 0

I asked this question a bit earlier and have only been able to gain a little ground. What I have is still not working as expected.

What I want to do is to share a number pad with 3 different forms. If the user clicks on box ‘a’, all of the numbers (from the anchor tag) as well as the focus should go into that input box. If the user clicks on box ‘b’, then all of the numbers (from the anchor tag) as well as the focus should go into that input box.

Can someone help me to get this correct?

function box(box) {
  if(box == 'a') {
    document.getElementById("a").focus();
    document.getElementById('a').value += '1';
    document.getElementById('a').value += '2';
  }else if(box == 'b') {
    document.getElementById("b").focus();
    document.getElementById('b').value += '1';
    document.getElementById('b').value += '2';
  }
}

function process(val){
  document.getElementById('a').value += val;
}

When the user clickes one of these anchor tags, I am expecting the value to be populated into the proper input box. The input box is first determined when the user clicks the anchor tag that sets the focus into the box they want to use.

STEP 1 Choose the input box to use and put focus:

<a href="#" onclick="box('a')">a</a><br />
<a href="#" onclick="box('b')">b</a><br />

STEP 2 Put the data into the box:

<a href="#" onclick="process('4');">4</a>
<a href="#" onclick="process('5');">5</a>


<form name="a">
  <input type="text" id="a" />
</form>
<form name="b">
  <input type="text" id="b" />
</form>
  • 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-18T01:38:36+00:00Added an answer on May 18, 2026 at 1:38 am

    Keep a variable around to track which pad is selected.

    var selected = 'a';
    
    function box(box) {
        selected = box;
        document.getElementById(selected).focus();
    }
    
    function process(val){
      document.getElementById(selected).value += val;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked a bit before. But looking around I
I know many have asked this question, but I think my situation is a
(I asked this question in another way , and got some interesting responses but
I asked this question before, Here however I think I presented the problem poorly,
I asked this question a while back but now I'm looking to implement an
I asked this question: Serial Port (rs232) in Mono for multiple platforms and this
I've asked this question to the forums on the Mootools website and one person
I was asked this question in a job interview. The interviewer and I disagreed
I originally asked this question on RefactorMyCode , but got no responses there... Basically
I was asked this question during an interview. They're both O(nlogn) and yet most

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.