PDA

View Full Version : 2 events in one onchange?



hantz
11-14-2007, 08:37 AM
i got to 2 onchange events...how can i mix them?
<select name="resp" onChange="enableDisable

(this,'listbox2','listbox1','listbox3','closhour','closhour1')" onChange="if (this.selectedIndex == 3

) { if(!confirm('you pick 3?')) this.selectedIndex=this.oldIndex}; if (this.selectedIndex == 4 ) { if(!

confirm('you pick 4?')) this.selectedIndex=this.oldIndex}"

onFocus="this.oldIndex=this.selectedIndex">
this way it not working...:(

jscheuer1
11-14-2007, 02:03 PM
Your code looks like garbage because you haven't used the forum's editor's proprietary code tags. In the advanced editor, hit the # symbol and put your code inside the:




tags that will then appear, or just type your own square bracketed tags (exactly as shown) and use those.

A general sort of answer though would be that events can be combined. You cannot use more than one event attribute of the same type for the same tag. Let's say you wanted to:


alert('here')

and:


alert('Hello!')

You could:


onchange="alert('here');alert('Hello!');"

Trinithis
11-14-2007, 04:53 PM
onchange = function(e) {
alert("hi");
alert("Hello");
myFunc(e);
. . .
};

Or you could use event listeners if you are game for learning that.