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

The Archive Base Latest Questions

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

I have the following document, where I plan to add some horizontal lines, one

  • 0

I have the following document, where I plan to add some horizontal lines, one for each line of a textbox, where lines should have a “name: number” structure.

<!DOCTYPE html>
<html lang="pt-br" xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="pragma" content="no-cache"/>    
    <title>Diagrama Audax</title>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>

    <style type="text/css">
        #sidebar {float: left; display: inline-block;}
        #drawing {left: 330px; position: relative;  display: inline-block}
        #Locais {width: 300px; height: 500px;}
        svg {background: #ddd; width: 500px; height: 500px;}
        td, textarea {margin: 0; padding: 0;}
    </style>
</head>

<body>
    <table>
        <tr id="tabela" cols="2">
            <td>
                <textarea id="Locais"></textarea>
            </td>
            <td>
                <svg id="svg">
                    <circle stroke="black" fill="red" cx="200" cy="200" r="100" opacity="0.1"/>
                    <line id="path" x1="0" y1="0" x2="200" y2="200" stroke="black"/>
                </svg>
            </td>
        </tr>
    </table>
</body>

<script>

    // A função abaixo pega a caixa de texto e associa o evento "draw" a ela
    $(function () {
        $("#Locais").keyup(function() {
            valueString = $("#Locais").val();
            if (valueString != "") {
                lines = valueString.replace("\r","").split("\n");
                CPs = [];

                for (i in lines) {
                    eachLine = lines[i];
                    tmpDict = {};
                    values = eachLine.split(":");
                    for (j in values) {
                        eachVal = values[j];
                        tmpDict[j] = eachVal;
                    }
                    CPs.push(tmpDict);
                }
                DrawUsing(CPs);
            }
        })
    });


    function DrawUsing (lista) {
        var svg = document.getElementById("svg");
        for (element in lista) {
            refname = lista[element][0];
            refdist = lista[element][1];
            var line = document.createElement ("line");
            line.setAttribute('stroke', "black");
            line.setAttribute('stroke-width', 1);
            line.setAttribute('x1', 0);
            line.setAttribute('x2', 100);
            line.setAttribute('y1', refdist);
            line.setAttribute('y2', refdist);
            svg.appendChild(line);
            console.log(document.getElementsByTagName("line").length);
        }
    }
</script>
</html>

As a “warm up”, I tried to manipulate the SVG adding lines to it each time I press a key. Having pasted the following text (just pasting it with control+V is enough to trigger keyup event), but although the svg child list increases, no additional line is seen.

What am I doing wrong? (a lot, I suppose, since I am very n00b with javascript, and direct manipulation of inline <svg> elements (as opposed to <object>) is very poorly documented, it seems…

Any help is most welcome, thanks for reading!

  • 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:39:31+00:00Added an answer on June 11, 2026 at 7:39 pm

    SVG elements go in the http://www.w3.org/2000/svg namespace so instead of

    var line = document.createElement ("line");
    

    use

    var line = document.createElementNS ("http://www.w3.org/2000/svg","line");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML document: <x> <a>Some text</c> <b>Some text 2</b> <c>Some text
If I have the following xml document: <xml> <data> <dataset name=X></dataset> </data> </xml> How
I have the following document: {_id: '4eb79ee1e60fc603788e7259', Name: 'name', Subsidiaries: [ { _id: '4eb79eeae60fc603788e7271',
I have the following code at JSfiddle: http://jsfiddle.net/ACG2D/ $(document).ready(function() { $('.testThis').click(function() { $('.regexValidation').each(function() {
I have the following XML document <?mso-infoPathSolution name=urn:schemas-microsoft-com:office:infopath:TCM-TCP:-myXSD-2012-02-20T14-33-22 solutionVersion=1.0.0.65 productVersion=14.0.0.0 PIVersion=1.0.0.0 href=https://devcoop.oceanspray.com/sites/TCM2/FormServerTemplates/TCM-TCP.xsn?> <?mso-application progid=InfoPath.Document
I have the following mongo document: { _id: 'someid', name: 'John Doe', address: {
I have the following document structure inside a mongodb collection: { _id: XXX, Name:
I have the following XML Document being loaded into C# Silverlight: <parent> <son name=Jim>
I have the following XML document: <database name=pressPlay> <table name=users> <column name=userID type=INT constraints=tableID_c
I have created the following document: var document = new Document(); document.Add(new Field(category, foo,

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.