Hi all, I'm a bit of a jobber with JS, so please excuse me.
I'm use prototype quite a lot for ajax calls, but have always used inline onclicks. I'm trying to be less obtrusive by creating event handlers/listeners.
I used to do this with the aid of pHp to place arguments into the function (usually via 'while loop'):
<li><a href="#" onclick="dofunction(arg1,arg2);">item 1</a></li>
<li><a href="#" onclick="dofunction(arg1,arg2);">item 2</a></li>
<li><a href="#" onclick="dofunction(arg1,arg2);">item 3</a></li>
At the moment I have this function:
Event.observe(window, 'load', function() {
Event.observe('myid', 'click', runme);
});
to react to
<li id="myid">Click Me </li>
This is all well and good and it works - when I click the item the 'runme' function runs.
Can anyone tell me how I can get any list item in a particular list to run 'runme' (I don't want to use a unique id for each item). Also, and more importantly, where can I place the arguments (arg1, arg2) in the HTML so that they can be passed to a function? I will be creating the list dynamically from DB entries.
Thanks in advance.