473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

object expected getElementById

25
I am using an xmlhttprequest to execute a php scipt to query a database. The result of the query are two variables $numrows, $numfields and two arrays $fieldnames[], $parts[][]. The lines with getElementById are saying
"document.getElementById(...) is null or not an object". If your trying to assign values to text fields or tags with ID's then you you getElementById, if you are trying to assign a values to variables, then use getElementByName. Is this correct?

I tried
Expand|Select|Wrap|Line Numbers
  1. numrows=response.getElementById("numrows");
  2.  
which gave me object doesn't support this property or method.

Expand|Select|Wrap|Line Numbers
  1. if (response.getElementById)
  2.  
gave me "failed".

This is the code
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. function Parts()
  3.     { 
  4.     var url="http://localhost/Project/parts.php"; 
  5.     if(window.XMLHttpRequest)
  6.     http = new XMLHttpRequest(); 
  7.     else if (window.ActiveXObject)
  8.     http  = new ActiveXObject(Microsoft.XMLHTTP); 
  9.     http.onreadystatechange = function()
  10.         { 
  11.         alert(http.readyState);
  12.         if(http.readyState == 4)
  13.             {
  14.             alert(http.status)
  15.             if(http.status == 200)
  16.                 {
  17.                 response = http.responseText;
  18.                 alert(response);
  19.                 if (document.getElementById)
  20.                     {
  21.                     alert("ok");
  22.                     numrows=document.getElementById("numrows");
  23.                     alert(numrows);
  24.                     numfields=document.getElementById("numfields");
  25.                     alert(numfields);
  26.  
  27.                     }
  28.                 else    
  29.                     {
  30.                 alert("Failed");
  31.                     } 
  32.                 }
  33.             } 
  34.         }
  35.         http.open("GET", url, true); 
  36.         http.setRequestHeader("text"); 
  37.         http.send(null); 
  38.     } 
  39. </script>
  40.  
  41. <script type="text/javascript" language="javascript">
  42.     function displayParts()
  43.     {
  44.     var fieldname = new Array();
  45.     var parts = new Array();
  46.     var numfields;
  47.     var numrows;
  48.     document.write('<tr>');
  49.     for (j=0; j < numfields; j++)
  50.         {
  51.         document.write('<td><div id="fieldname[j]"></td>');
  52.         }
  53.     document.write('<\/tr>');
  54.     for (i=0; i < numrows; i++)
  55.         {
  56.         document.write('<tr>');
  57.         for (j=0; j < numfields; j++)
  58.             {
  59.             document.write('<td><div id="parts[i][j]" /></td>');
  60.             }
  61.             document.write('</tr>');
  62.         }
  63.     }
  64.     </script>
  65.  
Can anyone point out where I am going wrong?

rpjd
Apr 26 '07 #1
2 1986
iam_clint
1,208 Expert 1GB
wheres the element numrows?
Apr 26 '07 #2
rpjd
25
wheres the element numrows?
As responseText is just a text string, getElementById is not a valid method. I am gonna try using getrequestHeader which is valid.
Apr 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Daniel | last post by:
Hi, I have problem to get the control id and set its visible to true/false(mean show/hide). here is my code: <%@ Control Language="vb" AutoEventWireup="false" Codebehind="ucNavbar.ascx.vb"...
11
by: westplastic | last post by:
This one is driving me insane. The script works perfect on Firefox, but Internet Explorer keeps complaining about "Error Object Expected" and stuff like that. I've run it through Firefox's Java...
7
by: Shanimal | last post by:
Hello- I'm running a php front end app on mysql. When viewing the page with Firefox, no error. When viewing with IE6, always get the following error: Line: 210 Char: 3 Error: Object...
1
by: finizaini | last post by:
I'm receiving an "Object Expected" Error (Line:309, Char:0). I'm confused as to what is happening.Also, I can't run this code using other browser such as Fire Fox. Thispage only can view using IE....
1
by: pratimapaudel | last post by:
function Showdiv() { var SelectStates = document.getElementById('Select1').value; if(SelectStates ="3") { document.getElementById("div2").style.display = "block"; } else ...
0
by: pratimapaudel | last post by:
My Control has the foloowing code <div id="<%#this.GetIDChain()+"#div1"%>"> <select id="<%#this.GetIDChain()+"#Select1"%>" onchange="LotteryResult_Showdiv(this);"> ...
7
by: EdEvans | last post by:
have the following code on a page: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Page.ClientScript.RegisterStartupScript(this.GetType(), "DoPreview",...
2
by: jc | last post by:
I'm trying the below and getting OBJECT EXPECTED error in javascript. On my aspx page I have this java script block: <script language="javascript" type="text/javascript"> function...
2
by: tridirk | last post by:
Hi; I am getting a Objceted Expected Error on my forum site. I can't find what is wrong? Line: Char: Error: Object expected Code:0 the site is My SMF Forum
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.