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

The Archive Base Latest Questions

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

I seem to be having trouble with passing the value of an input box

  • 0

I seem to be having trouble with passing the value of an input box to anything else in my javascript.
It’s not producing any errors – and I remember reading somewhere that you can have issues if the document hasn’t finished loading – but I’m pretty sure it has!

The code in question is as follows in the javascript:

var address = getElementById(addyInput).value;
document.getElementById('add').innerHTML = address;

And in the HTML

<form>
<input name="addyInput" placeholder="Don't forget postcode!">
</form>

<button id="start" onclick="initialize()">Start!</button>

<p>Address Test
<div id="add"></div>
</p>

I know that the button itself is working as it fires the rest of my code fine without the offending code – however the moment I uncomment that little block at the top, it just does nothing. (no errors etc)

Any help on that one would be hot! Thanks 🙂

Update:

I now have it working! Thanks muchly for all the help!!

  • 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-21T11:14:30+00:00Added an answer on May 21, 2026 at 11:14 am

    Your form needs to look like this (add an id attribute):

    <form>
    <input id="addyInput" name="addyInput" placeholder="Don't forget postcode!">
    </form>
    

    And the first line of Javascript needs to look like this (since getElementById is expecting an ID rather than a name).

    var address = getElementById('addyInput').value;
    

    Additionally, getElementById expects the id argument to be a string (hence the quotes). If you pass it addyInput without quotes, it’ll try to interpret addyInput as a variable which has a value of undefined and you won’t get back the DOM element you want.


    Or, if you were using jQuery, you could leave the form markup as-is and change the Javascript to this:

    var address = $('input[name=addyInput]').val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a bit of trouble. It does not seem to be a
I'm having trouble with animating with CAAnimation, it doesn't seem to give me any
I seem to be having trouble testing the slick javascript things I do with
I seem to be having trouble with my code. I need to say: if
This may be something common and trivial, but I seem to be having trouble
I'm having trouble with MySQL or Python and can't seem to isolate the problem.
I'm having trouble trying to manipulate music using buttons I can't seem to make
I'm having trouble getting my head around algorithm analysis. I seem to be okay
I'm having trouble with my DatabaseConnection class. I cannot seem to get $dbUser or
I'm having trouble with the copying entities between multiple databases. I can't seem to

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.