Its happening because (as someone pointed out in a previous reply) the DOM node 
does not exist yet .....

you need to wrap the code in observers...

for example...

Event.observe(window,'load',function() {

    $('TheElementToHideObserver').observe('click',function() {


//Then your html

<input type="submit" id="TheElementToHideObserver" value="Hide First Name" />
<hr />
<input type="text" name="firstname" id="firstname" />


Simple as that


Alex Mcauley
  ----- Original Message ----- 
  From: Eugene Hourany 
  Sent: Monday, November 09, 2009 7:04 AM
  Subject: [Proto-Scripty] Re: Some basic basic stuff

  I never put in a name attribute, that could be part of the problem.

  I solved it by putting it in a function that's called by onclick, and it 
worked. I was able to reference it the old fashioned JS way, and prototype's 

  Now all I want to know is how to load and parse a JSON file using the same 



  On Sat, Nov 7, 2009 at 1:45 PM, kstubs <> wrote:

    Try naming the ID attribute different than the NAME attribute.

    On Nov 7, 12:49 pm, bill <> wrote:
    > Eugene Hourany wrote:
    > > Hi all,
    > > I'm tearing my hair out trying to figure out why I keep getting a
    > > "element is null" error. Here's what my code looks like:
    > > $('firstname').hide();
    > > and I have
    > > <input id="firstname" name="firstname" value="" />
    > > and I get
    > > Error: $("firstname") is null
    > > Source File:
    > > file:///C:/Documents%20and%20Settings/142253/Desktop/test/index.html#
    > > Line: 14
    > > I'm doing this locally from my desktop. I'm using prototype 1.6.1.
    > do you have the input declaration before the execution of the
    > "$('firstname').hide();"
    > If you execute the js before the input is declared, the id will not exist.
    > bill
    > --
    > Bill Drescher
    > william {at} TechServSys {dot} com


You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to