Forum Moderators: open

Message Too Old, No Replies

conditional function at onChange event

         

ayushchd

6:49 pm on Jul 30, 2007 (gmt 0)

10+ Year Member



I want two functions to be executed at the onChange even of a drop-down box :
1. One function will be executed on every on Change event
2. The other function shud be executed only when a div named '1' is visible.

I know this is wrong but this is somethin like what I want :

<select name="company" onChange = "javascript : callAjax(this.value); if (document.getElementById){
obj2 = document.getElementById('1');
if (obj2.style.display == ""){ loader('validate', this.qty.value,this.value); }}">

Fotiman

7:37 pm on Jul 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'd do this in a less obtrusive way (remove that yucky inline script from your markup).

window.onload = function(){
// Attach event handlers
var company = document.getElementById("company");
company.onchange = function() {
callAjax(this.value);
obj2 = document.getElementById('1');
if (obj2.style.display == ""){
loader('validate', this.qty.value,this.value);
}
}
}


<select name="company" id="company">

I haven't tested the above example. If I were doing it, I'd use the Yahoo UI Library's Event utility for attaching the event handler, and the DOM utility for changing the style.