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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:57:36+00:00 2026-05-24T10:57:36+00:00

I am creating an application that uses the same number pad to fill out

  • 0

I am creating an application that uses the same number pad to fill out two separate text style form values using javascript.

I found out how to gather a div ID for use inside of a function (for say toggling the hide value), but I need to save this value somehow so that I can know which field to put the numbers into when they come in.

I tried using a global variable for this, but it does not seem to work as the ID does not seem to be recorded as a String value.

The code that I am using does toggle the show/hide attribute, but if I use an alert box to pop what the variable I am using as storage is it reads [object HTMLDivElement]

My script looks like this (bear in mind that I am a noob to javascript).

<script type="text/javascript">
    <!--
    keypad.display="none";
    //Classes for the numberpad on the text fields.

        var padName = ""; //Storage for the name of the current pad.

        function numPad(field) {
            var pad = document.getElementById("keypad"); //manipulating pad.
            var ref = document.getElementById(field);//gather the field info.
            if (pad.style.display == "block") { //Open or close?
                pad.style.display = "none"; //Blank out.
                padName = "";   
            }
            else {
                pad.style.display = "block";//Set to refer to correct field.
                padname = ref;
                alert (ref); 
            }
        }

        function click(id) {
            var key = document.getElementById(id);
            var total = padName.value();
            if (key == "Backspace") total.slice(0, -1);
            else if (key == "Enter") numPad("blanck");
            else total += key;
            padName.value = total;
        }
    -->
</script>
  • 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-24T10:57:36+00:00Added an answer on May 24, 2026 at 10:57 am
    // to get the ID by direct property access of the DOM element
    var ref = document.getElementById(field).id;
    

    and then ref stores the ID value.

    I would suggest:

    // create an object to store app-wide settings
    // access properties like this: appSettings.propertyName
    var appSettings = { padName: "" };
    
    ...
    
    var ref = document.getElementById(field).id;
    appSettings.padName = ref;
    

    to avoid polluting the global namespace.

    To get/set the value of the pad, you’ll need to do this:

    // to get
    var total = document.getElementById(appSettings.padName).value;
    
    // to set
    document.getElementById(appSettings.padName).value = "something";
    

    You should read up on DOM objects and properties.

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

Sidebar

Related Questions

I am creating an application that uses popups. However, I would like to animate
I am creating an ASP script that uses the application object to store the
Hi I am creating my first WPF application that uses Ribbons. The problem I
I'm creating a desktop application using Visual studio and C# that uses MySQL. I
I'm creating an application that uses an ImageSwitcher to show some images. I want
I am creating a web application that uses JQuery's AJAX calls as it deals
I'm am creating an ASP.NET 2.0 web application that uses a BasePage.aspx that is
I am creating a Facebook iFrame tab application that features weekly interviews and uses
I'm creating an application in C# 3.5 that uses the AutoCAD API to read
I'm creating an application that will store a hierarchical collection of items in an

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.