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

It is advisable to use tables in HTML pages (now that we have CSS)?
I have a page (page1.html) which references a css file (style1.css) All is good.
I have HTML that includes symbols such as the Trademark TM as superscript (™).
On a page that I'm designing I have a form with one input of
Suppose I have following html page. <html> <head> <link type=text/css rel=Stylesheet href=css/some.css /> </head>
I have an html page. On that page I want to open popup window.
I have an HTML 5 web page using CSS 3 and have tested it
I have to deploy my php/html/css/etc code to multiple servers and i am looking
I have the following HTML (note the CSS making the background black and text
We have a rather simple site (minimal JS) with plain html and CSS. It

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.