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

The Archive Base Latest Questions

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

I am loading data from SQL in a while loop which draws my SVG.

  • 0

I am loading data from SQL in a while loop which draws my SVG. within my data each record is has its own ID.

I am trying to load the ID through the getelementbyId, but keeps returning null values.

Here is my code.

#!/usr/bin/perl
use DBI;
use CGI::Carp qw(fatalsToBrowser);
print "content-type: text/html\n\n";
print "Content-Type: image/svg-xml\n\n" ;
$dbh = DBI->connect ('dbi:Oracle:******','*****','*****')
|| die "database connection not made: $DBI::errstr";

$sth = $dbh->prepare("SELECT Find_id, xcoord, ycoord, gisteach.finds.type, gisteach.class.type, depth, name, period, use FROM GISTEACH.finds, GISTEACH.class where gisteach.finds.type = gisteach.class.type");
$sth->execute();

$sth1 = $dbh->prepare("SELECT lowx, hix, lowy, hiy, Field_id, owner, GISTEACH.FIELDS.crop, GISTEACH.crops.crop, name from GISTEACH.FIELDS, gisteach.crops where gisteach.crops.crop = gisteach.fields.crop");
$sth1->execute(); 

print qq(<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
  "http://www.w3.org/tr/2000/cr-svg-20001102/DTD/svg-20001102.dtd">);  
print qq(<svg width="20cm" height="20cm" viewBox="-1 -18 20 20" onload="getid(ID)">);

print qq (<script type="text/ecmascript">);
print qq (<![CDATA[  

  // with out this (onload) i still have teh same issue.
  function getid(ID){ 
  (document.getElementById('ID'));
   }
  function MakeTransparent(evt) {
      evt.target.setAttributeNS(null,"opacity","0.5")
    }
  function MakeOpaque(evt) {
      evt.target.setAttributeNS(null,"opacity","1")
    }   


  function buttonClick(){
      var type = document.getElementById('ID');
      var data = type.getAttribute('d')
      var data2 = type.getAttribute('d2')
      var data3 = type.getAttribute('d3')     
      alert ("This Find can be placed in the: " + data2 + " age. In which its primary use was; " + data3 );
    }

    function buttonClick2() {  
      var type = document.getElementById('ID')             
      var data1 = type.getAttribute('b')
      var data2 = type.getAttribute('c')

      alert ("Owner of this field is: " + data1 + "  Where " + data2 + " are growing" );
    }
    ]]>);   
print qq (</script>);

while (@data = $sth1->fetchrow_array()) {

print qq(    
  <g transform="scale(1,-1)" > 
      <polygon points="$data[0],$data[2] $data[1],$data[2] $data[1],$data[3] $data[0],$data[3]" 
        fill="green"  
           ID="$data[4]"  
             b="$data[5]"
              c="$data[8]"
                opacity="1"
              stroke="black" 
            stroke-width="0.05"
         onmouseover="MakeTransparent(evt)" 
       onmouseout="MakeOpaque(evt)" 
    onmouseup="buttonClick2()"/>      
   </g>                                   
  );    
}
while (@data = $sth->fetchrow_array()) {
print qq(  
    <g transform="scale(1,-1)"  >
       <circle           
         ID="$data[0]" 
          cx="$data[1]"        
            cy="$data[2]" 
              r="0.17"
            d="$data[6]"
          d2="$data[7]"
        d3="$data[8]"                
      fill="red"
     onmouseup="buttonClick()"/>

</g>    
  ); 
 }  enter code here

Thanks

  • 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-15T00:55:30+00:00Added an answer on June 15, 2026 at 12:55 am
    function getid(ID){ 
        (document.getElementById('ID'));
    }
    

    should become

    function getid(ID){ 
        return document.getElementById(ID);
    }
    

    Otherwise you’re just looking for an element with id of value ‘ID’

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

Sidebar

Related Questions

I have a dropdownlist for which I am loading data from excel. Excel has
I have implemented delta detection while loading data warehouse from transaction systems using an
I have a form that is loading quite an amount of data from SQL
I have this error while using DiH for importing data from SQL Server to
I am loading data from table to flat file destination, where my flat file
Currently I am loading data from a previous session into my application using the
We are loading data from db: var somethings = Context.SomethingSet.ToList(); Then someone deletes or
I'm loading data from a MySQL database into a C# .NET application. The data
I have a flash file that is loading data from XML file. After I
In my application, I'm loading some data from a file. This can fail and

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.