PDA

View Full Version : passing a parameter to an event



carlitos_way
Apr 18th, 2007, 09:56 AM
hi all, in my page i have an inputfield and a button:


<span>
<input id="codiceFiscale" class="field text req" value="" maxlength="16" size="16" name="codiceFiscale"/>
<label for="codiceFiscale">
Codice Fiscale
<a style="color: red;">*</a>
</label>
</span>
<span id="forCodFiscale" class="finder icon popup">
<a id="buttonFinder" title="Search the user in the archive."/>
</span>
this piece of code is repeated different times over the page, with different inputtext and buttons (with class=finder icon popup).

in the Javascipt side, i have this code that checks for elements with class = popup:

function initPage() {addEvent('onclick', 'popup');}

function addEvent(type, ev) {
327 var el = getElementsByClass(ev);
328 for (var i=0;i<el.length;i++) {
...
346 else if (ev == 'popup')
347 el[i].onclick = function () {
348 return selectUsers(el[i])
349 }
350 else
351 el[i].onclick = function () {
352 alert('event unknown')
353 }
354 }
355 }
356}

now the problem is that the object el[i] is undefined. i tried also passing el[i].id, but firebug also told me that its value is null..

how can i pass a parameter so that i know which is the id of the button, or of the textfield, from which the event was originated??