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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:55:00+00:00 2026-06-15T13:55:00+00:00

I am trying to create an array of simple text inputs inside an SVG

  • 0

I am trying to create an array of simple text inputs inside an SVG that is created dynamically using javascript.

First I was doing it in PHP and there the snippet would look like this:

for ($row=0; $row<7; $row++)
{
for ($col=0; $col<7; $col++)
{
    $fx=130+100*$col;
    $fy=120+100*$row;
    echo "<foreignObject x="".$fx."" y="".$fy."" width="50" height="80">\n<body xmlns="http://www.w3.org/1999/xhtml">\n<form><input type="text" width="1"/ style="font-size:48px; border:none;"></form>\n</body>\n</foreignObject>";
}
}    

Then in javascript I would try it for a single instance like this but I did not get this to work.

var field = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
field.setAttribute("x", "130");
field.setAttribute("y", "120");
field.setAttribute("width", "50");
field.setAttribute("height", "80");
mySvg.appendChild(field.cloneNode(true));
var s = '<body xmlns="http://www.w3.org/1999/xhtml"><form><input type="text" width="1" style="font-size:48px; border:none;"></form></body>';
var s1 = document.createElement(s);
field.appendChild(s1);
</script>

Any hints? Or should I switch to a completely different implementation (e.g. CSS)?

  • 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-15T13:55:02+00:00Added an answer on June 15, 2026 at 1:55 pm

    document.createElement requires an element name as an argument and creates a single element, it doesn’t parse arbitrary html/xml content.

    You can use DOMParser to parse a string of markup.

    As for the PHP you probably need to escape the internal double quotes in the echo.

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

Sidebar

Related Questions

I'm trying to create a really simple to do list using an array and
I am trying to create a simple appplication that can read from a text
I am trying to create an array or list that could handle in theory,
I'm trying to create an array of strings that can be randomized and limited
I'm trying to create an array of structs and also a pointer to that
I'm trying to create a simple form that adds a user new User(). But
I'm trying to create a small app that takes a base text template with
I am trying to create a simple image slideshow type thing with the Javascript
i'm trying to create a simple autocomplete textbox that takes the suggestions from an
I am trying to display statistics from a simple text file using arrays in

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.