I have the following code of select control
<
select id="cboState" onchange="distfill();" " >this onchange event is not firing in Firefox and netscape but working fine in IE and opera.
PLease tell me how can i resolve my problem.
RAGHAV
![]()
MVP ASP/ASP.Net Read My Blog
MARK THE POST AS ANSWER IF IT HELPS U.
"Success doesn't come to you…you go to it."--Marva Collins
"Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous
![]() |
0 |
![]() |
Works for me. Maybe your problem is the extra quote mark that you have in <select id="cboState" onchange="distfill();" " > that should be <select id="cboState" onchange="distfill();">
NC...
![]() |
0 |
![]() |
The problem was different actually on change event was firing actually but
one thing was different for these browsers
ie.
i had 2 <select> controls on my page one is for filling states
and other combo was filling on change of state .
now in my java function i had written
these lines of code to add new option in second combo
newOpt = document.createElement("OPTION");newOpt.text = distaccToStte[i].disname;
newOpt.value = distaccToStte[i].disvalue;
cboDist.add(newOpt, i + 1);
now the line cboDist.add(newOpt, i + 1); does not work for mozilla and netscape
so for this
i wrotecboDist.appendChild(newOpt);
this work for netscape and mozilla
but by doing this my problem was that this now doesn't work for opera and IE 6.0
so to resolve that finally my sucessfull code was
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]); if (win_ie_ver <= 6.0) {var newOpt; //cboDist.options.length = 1;for (var i = 0; i < distaccToStte.length; i++) { // alert('Hello in distfill for ');newOpt = document.createElement("OPTION");newOpt.text = distaccToStte[i].disname;
newOpt.value = distaccToStte[i].disvalue;
//cboDist.appendChild(newOpt);cboDist.add(newOpt, i + 1);
}
}
else {var newOpt;cboDist.options.length = 1;
for (var i = 0; i < distaccToStte.length; i++) { // alert('Hello in distfill for ');newOpt = document.createElement("OPTION");newOpt.text = distaccToStte[i].disname;
newOpt.value = distaccToStte[i].disvalue;
cboDist.appendChild(newOpt);
//cboDist.add(newOpt, i + 1);}
}
ie. i put two conditions that for I.E 6.0 and opera one condition follows and for mozilla and ntescape other follws.
Please mark as Answer if it Helps u.
RAGHAV
![]()
MVP ASP/ASP.Net Read My Blog
MARK THE POST AS ANSWER IF IT HELPS U.
"Success doesn't come to you…you go to it."--Marva Collins
"Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous
![]() |
1 |
![]() |
This should work in all browsers:
<script type="text/javascript">
<!--
////////////////////////////////////////////////////////////////////////////////////////
// Usage:
// var elementRef = '<%= DropDownList1.ClientId %>';
// var optionText = 'New York';
// var optionValue = 'NY';
// addOption(elementRef, optionText, optionValue);
////////////////////////////////////////////////////////////////////////////////////////
function addOption(elementRef, optionText, optionValue)
{
if ( typeof elementRef == 'string' )
elementRef = document.getElementById(elementRef);if ( elementRef.type.substr(0, 6) != 'select' )
return;var newOption = document.createElement('option');
newOption.appendChild(document.createTextNode(optionText));
if ( arguments.length >= 3 )
newOption.setAttribute('value', optionValue);elementRef.appendChild(newOption);
}
// -->
</script>NC...
![]() |
0 |
![]() |
Hi,NC01
U was right ,my above specified code was running correctly in mozilla,IE6.0,nescape,opera
but in IE 7.0 it was not working .
I tried ur code and now it is working with IE7.0 also
Thanks for ur support.
RAGHAV
![]()
MVP ASP/ASP.Net Read My Blog
MARK THE POST AS ANSWER IF IT HELPS U.
"Success doesn't come to you…you go to it."--Marva Collins
"Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous
![]() |
0 |
![]() |