Puccini
Neues Mitglied
Hi
ich will einem Element dynamisch mehrere Funktionen bei onclick zuweisen, doch leider scheitere ich an einer fehlermeldung...
Hier die Funktion zum Adden:
Die fehlermeldung:
wie kann ich nach dem laden der seite einem button weitere events zuweisen, so das aber die alten noch erhalten bleiben? danke 
#### EDIT ####
Hat sich erledgit, ich muss nur setAttribute und getAttribute nutzen XD
ich will einem Element dynamisch mehrere Funktionen bei onclick zuweisen, doch leider scheitere ich an einer fehlermeldung...
Hier die Funktion zum Adden:
Code:
[LIST=1]
[*][FONT=monospace][COLOR=#666666][I]/*[/I][/COLOR][/FONT]
[*][FONT=monospace][COLOR=#666666][I] fügt einem bestimmten Objekt ein weiters Event hinzu[/I][/COLOR][/FONT]
[*][FONT=monospace][COLOR=#666666][I] @param String ObjektID Die ID des HTML-Objektes[/I][/COLOR][/FONT]
[*][FONT=monospace][COLOR=#666666][I] @param String Event Das Event welches erweitert werden soll (z..B: onclick)[/I][/COLOR][/FONT]
[*][FONT=monospace][COLOR=#666666][I] @param String FunctionName der name der Funktion welche angehangen wird (mit () am Ende)[/I][/COLOR][/FONT]
[*][FONT=monospace][COLOR=#666666][I]*/[/I][/COLOR][/FONT]
[*][FONT=monospace][COLOR=#000000][B]function[/B][/COLOR] add_event[COLOR=#009900]([/COLOR]ObjektID[COLOR=#339933],[/COLOR] Event[COLOR=#339933],[/COLOR] FunctionName[COLOR=#009900])[/COLOR][/FONT]
[*][FONT=monospace][COLOR=#009900]{[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#000000][B]var[/B][/COLOR] tmpObjekt [COLOR=#339933]=[/COLOR] document[COLOR=#339933].[/COLOR]getElementById[COLOR=#009900]([/COLOR]ObjektID[COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR]tmpObjekt[COLOR=#009900])[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#009900]{[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#000000][B]var[/B][/COLOR] oldEvent [COLOR=#339933]=[/COLOR] String[COLOR=#009900]([/COLOR]tmpObjekt[COLOR=#339933].[/COLOR]attributes[COLOR=#009900][[/COLOR][COLOR=#0000ff]Event[/COLOR][COLOR=#009900]][/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][/FONT]
[*][FONT=monospace] alert[COLOR=#009900]([/COLOR]oldEvent[COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR]oldEvent [COLOR=#339933]&&[/COLOR] oldEvent[COLOR=#339933].[/COLOR]length [COLOR=#339933]>[/COLOR][COLOR=#cc66cc]0[/COLOR][COLOR=#009900])[/COLOR][/FONT]
[*][FONT=monospace] tmpObjekt[COLOR=#339933].[/COLOR]attributes[COLOR=#339933].[/COLOR]add[COLOR=#009900]([/COLOR]Event[COLOR=#339933],[/COLOR]oldEvent[COLOR=#339933]+[/COLOR][COLOR=#0000ff]";"[/COLOR][COLOR=#339933]+[/COLOR]FunctionName[COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#b1b100]else[/COLOR][/FONT]
[*][FONT=monospace] tmpObjekt[COLOR=#339933].[/COLOR]attributes[COLOR=#339933].[/COLOR]add[COLOR=#009900]([/COLOR]Event[COLOR=#339933],[/COLOR]FunctionName[COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR][/FONT]
[*][FONT=monospace] [COLOR=#009900]}[/COLOR][/FONT]
[*][FONT=monospace][COLOR=#009900]}[/COLOR][/FONT]
[/LIST]
Code:
[FONT=monospace]Fehler[COLOR=#339933]:[/COLOR] tmpObjekt[COLOR=#339933].[/COLOR]attributes[COLOR=#339933].[/COLOR]add is not a [COLOR=#000000][B]function[/B][/COLOR][/FONT]

#### EDIT ####
Hat sich erledgit, ich muss nur setAttribute und getAttribute nutzen XD
Code:
[FONT=monospace]tmpObjekt.getAttribute(Event)[/FONT]
Zuletzt bearbeitet: