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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:21:49+00:00 2026-05-23T05:21:49+00:00

In my HTML code I have a button that when pressed runs a javascript

  • 0

In my HTML code I have a button that when pressed runs a javascript function. This is the HTML code for the button:

<button type="button" onclick="repeatName()">Click me!</button>

I want the user to enter something into a text field (which is inside of a form). This is the code for the text field:

<input type="text" name="txtName" />

I want this div’s innerHTML to be changed according to the information put in the name textbox once the button is pressed. This is the code for the div:

<div name="editThis" width="50px" height="50px" border="1px">

</div>

When the button is clicked, I want it to run the function below. It is supposed to change the innerHTML of the div.

function repeatName() {
    var editField = document.getElementsByName("editThis").innerHTML;
    var repeatedName = document.theForm.txtName.value;

    editField = (repeatedName + " is the value.")

}

THE PROBLEM IS that whenever the button is clicked, I see this error in the Firefox error console:

Error: uncaught exception: [Exception... "Cannot modify properties of a WrappedNative"  nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)"  location: "JS frame :: chrome://global/content/bindings/autocomplete.xml :: onxblpopuphiding :: line 825"  data: no]

What is this error and how can I correct it?

  • 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-23T05:21:49+00:00Added an answer on May 23, 2026 at 5:21 am

    According to the documentation, document.getElementsByName(str) returns “a list of elements”.

    It’s clear that “a list of elements” doesn’t have a singular .innerHTML property. I’d guess that the specific error relates to your browser’s internal mechanism for representing that list in its own WrappedNative type.

    Iterate the results instead; in your case, you only need the first result, so get it with the array accessor syntax [0].

    But, since name properties relate to form components, you should use id instead. Retrieving an element by ID is easier, since IDs are [supposed to be] unique.

    Also, since Javascript has no references, you cannot store innerHTML in a variable and change it expecting the original property to change; you must make the assignment in the same statement in which you notate innerHTML:

    function repeatName() {
        var editField = document.getElementsById("editField");
        var repeatedName = document.theForm.txtName.value;
    
        editField.innerHTML = repeatedName + " is the value."
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a submit button that is a block of HTML code because of
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have this HTML code for radios: <input type='radio' name='a_27' value='Yes' id='a_27_0' /> <input
Having problems with IE8... I have a button that onclick fires the showImageBrowser() function.
my aspx (html) code is like below : this is first button (something that
I have this code in my HTML form: <form action=cart.php method=post> <input type=hidden value=1
I have ASP.Net code generating my button's HTML for me using divs to get
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have html code like this <tr class=odd> <td><b>Reason for Termination:</b></td> <td>this has bunch
I have the following html code: <h3 id=headerid><span onclick=expandCollapse('headerid')>&uArr;</span>Header title</h3> I would like 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.