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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:16:41+00:00 2026-05-24T12:16:41+00:00

I have an html/css page that is supposed to use an html table layout

  • 0

I have an html/css page that is supposed to use an html table layout full of buttons to simulate a t9 keypad layout.

On the page I have a form that includes two text fields. I want to use the table/keypad values to fill in the text fields with numbers via javascript.

I was able to associate a variable with a string that describes which field I wish to fill in with the data, but when I call for the current value of the field I get an error (console.log) that says “cannot read property ‘x’ of ‘undefined’.

Here is my function.

function place(id) {
        var key = ""; //Ensure that this is a string, not number
        key = document.getElementById(id).id; //Get the key value.
        console.log(key);
        var total = ""; //initialize variable.
        console.log(appSettings.padName);
        total = nums.element[appSettings.padName].value; //Grab total.
        //if (total.contains("Click")) total = "";
        console.log(total);
        if (key == "-1") total.slice(0, -1); //backspace.
        else if (key == "-2") numPad(appSettings.padName); //Enter.
        else total += key; //concat to end of the String.
        document.getElementById(appSettings.padName).value += total; //place update.
    }

I am calling this function with the following html

<div id="nums">
<form name="nums">
    <h3>
    Cell number: <input type="text" id="cell" value="" class="inputText"      size="10" onclick="numPad('cell')" name="cell" /><br/><br/>
    <div id='group'>
    Party size: <input type="text" value="" class="inputText" size="10" onclick="numPad('group')" name="group" /><br/><br/>
    </div>
    <input type="submit" value="Submit" class="button" />
</h3>

*note that each field has a different ID system.

The function that gathers the variable is working correctly gathering the div ID in a string format (aka ‘cell’). If you need more information to help I am happy to supply 😛

  • 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-24T12:16:42+00:00Added an answer on May 24, 2026 at 12:16 pm

    I’d go about this from a different approach, entirely. The best solution would be to listen for a click event on the <table>, and from there you can grab which key has been clicked, and update one of the inputs accordingly. This practice is called Event Delegation, and it is very efficient.

    There are a few faults with your current javascript. Firstly, you don’t need to initialize variables and assign them a “type”, before assigning them your intended values. As well, you don’t need to look up an element by it’s ID simply to grab the ID again, this is wasteful. I notice that you’re also referring to a number of global variables in your function, this is generally bad practice.

    Another note, the information that Chris Lively provided you with, re: semi-colons is blatantly false. There are no issues with your original if-statements. You can learn more from this post: http://inimino.org/~inimino/blog/javascript_semicolons

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

Sidebar

Related Questions

tl;dr I have an HTML+CSS page layout using positioned and scrolling boxes to simulate
I'm using the Blueprint CSS grid for my HTML page. I have a table
I have a HTML page that is generated by JavaScript (JQuery). It makes use
I have an HTML 4.01/CSS 2.1 document that includes an H3 heading followed by
I have an HTML table in my page that I'm trying to replace with
I have a HTML page that is supposed to display a calendar. There is
I have a web page that has an HTML table generated by an ASP.NET
I have a page (page1.html) which references a css file (style1.css) All is good.
I have one page website only using HTML, CSS and JavaScript. I want to
I have the following html/css that is causing problems in Firefox 1.5 and 2,

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.