On Mar 4, 3:51 am, janrmr <jan...@gmail.com> wrote:
> hi to all expert
>
> How can i drag an item when using DOM , so far I am receiving an error
> in prototype.js line 1903 "element is null"
>

That error nearly always means that you're calling a Prototype (or
scriptaculous) method on an element which doesn't (yet) exist.

> here is my simple code
>
> <script type="text/javascript"
>         src="javascript/prototype.js"></script>
> <script type="text/javascript"
>         src="javascript/scriptaculous.js"></script>
>
> <script>
> function imagedrag(name)
> {
>     new Draggable(name);}
>
> </script>
>   <script>
> function gen()
> {
> document.getElementById("wa").innerHTML="<div id='image1'><img
> src='html.gif'></div>";}
>
>   </script>
>
> <body onload="gen()">
>
>            <p id="wa"></p>
>
> <script type="text/javascript">
>             imagedrag('image1');
>
>          </script>

You've said to call 'gen' when the page finishes loading, but
'imagedrag' will be called during the loading, before you have created
'image1'.

Colin
--~--~---------~--~----~------------~-------~--~----~
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