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() {
    $('firstname').hide();


});
});

//Then your html


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


....

Simple as that

HTH


Alex Mcauley
http://www.thevacancymarket.com
  ----- Original Message ----- 
  From: Eugene Hourany 
  To: prototype-scriptaculous@googlegroups.com 
  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 
way.

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

  Thanks!

  Eugene


  On Sat, Nov 7, 2009 at 1:45 PM, kstubs <kst...@gmail.com> wrote:


    Try naming the ID attribute different than the NAME attribute.


    On Nov 7, 12:49 pm, bill <will...@techservsys.com> 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 & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to