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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:20:27+00:00 2026-06-11T19:20:27+00:00

I have this JS code which adds some HTML inside a tbody : thestring='<tr><td><input

  • 0

I have this JS code which adds some HTML inside a tbody:

    thestring='<tr><td><input type="text" name="entry-'+s+'-api" value="'+getItem('entry-'+s+'-api')+' /></td><td><input type="text" name="entry-'+s+'-talk" value="'+getItem('entry-'+s+'-talk')+' /></td><td><input type="text" name="entry-'+s+'-url" value="'+getItem('entry-'+s+'-url')+' /></td></tr>';

    document.getElementById('table').innerHTML+=thestring;

Bit long line, I know…

So when I run it, thestring is evaluated, correctly, to this:

<input type="text" name="entry-0-api" value="http%3A%2F%2Flego.wikia.com%2Fapi.php /><<input type="text" name="entry-0-talk" value="User_talk%3AUltrasonicNXT /><input type="text" name="entry-0-url" value="http%3A%2F%2Flego.wikia.com%2Fwiki%2FUser_talk%3AUltrasonicNXT />

However, this is the content that gets added:

<tr><td></td></tr>

So where did the rest go?

This is the relevent HTML:

<form action="change.js" method="GET">
   <table>
      <tbody id="table">
      </tbody>
   </table>
</form>
  • 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-06-11T19:20:28+00:00Added an answer on June 11, 2026 at 7:20 pm
    value="'+getItem('entry-'+s+'-api')+' />
    

    Incorrect markup. No closing quote on attribute value. Chrome is doing its best to clean up the mistake.

    But, in any case, you shouldn’t be building markup strings this way. If there are any HTML-special characters in the getItem value, then they’ll be able to leak into markup. If any of that content comes from an untrusted third-party, this HTML injection is not only a bug but a security hole.

    document.getElementById('table').innerHTML+=thestring;
    

    Never do this. This converts the entire current DOM of the table into HTML markup, adds to that string, and parses it all back in into new objects, replacing the old ones. This is slow and loses any information that doesn’t serialise to HTML (such as event handlers or form field values).

    It is much more reliable to alter the document’s live DOM nodes directly than to mess about with HTML markup. This fixes both problems. eg.:

    var row= document.getElementById('table').insertRow(-1);
    ['api', 'talk', 'url'].forEach(function(prop) {
        var name= 'entry-'+s+'-'+prop;
        var input= document.createElement('input');
        input.type= 'text';
        input.name= name;
        input.value= getItem(name);
        row.insertCell(-1).appendChild(input);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html script with the following code <input type=text name= id=PrDisplay onkeyup=calcCosting()/></td>
I have this code, which creates an image, and then adds some effects to
I have this code which adds a x number of views to a Multiview
I have this code which will include template.php file from inside each of these
I have the following code which adds some arrays to a hashmap but then
I have some code which adds a tooltip to all links. Now, the page
I have some code which calculates the totals of the input in a row
I have have some code which adds new cells to a table and fills
I have some code which adds the word _manual onto the end of a
I have this code which does the trick: #include <stdio.h> int main() { int

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.