YUI :
YUI
, , script
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
and then you can use custom events (everywhere in HTML) fnSubscriberChange - inside this Func you can do whatever you want. You can put your logic for changing the text field here and depend on the value of the "Changed selection" field - call the desired function. The logic, which depends on listening to events, is understandable and easily modified; The YUI library supports all browsers, so you should not consider browser features.
Text field and selection fields:
<input type='text' id='id_text_fld' value=''/>
<select id='id_sel_one'>
<option value="test1">Test1
<option value="test2">Test2
</select>
<select id='id_sel_two'>
<option value="test3">Test3
<option value="test4">Test4
</select>
Script for events:
<script>
(function() {
var onChangeValue = new YAHOO.util.CustomEvent("onChangeValue");
YAHOO.util.Event.on( ['id_sel_one', 'id_sel_two'], 'change', fnCallback, this);
fnCallback = function(e) {
alert("This elem:" + this.id+ " changed value to:" + this.value);
onChangeValue.fire({dom_el: this});
}
onChangeValue.subscribe(fnSubscriberChange);
fnSubscriberChange = function(type, args) {
alert("Event type:" + type + " dom el id:" + args[0].dom_el.id );
var dom_el = args[0].dom_el;
};
})();
</script>
source
share