Zdravim programatorov,
mam jednoduchu AJAxovou funkciu, ktora funguje v IE aj FF, avsak v IE nie. F-cia sa spusta pri zmene hodnoty selectu, ak by niekomu nebolo jasne. Premenna "s" je samotny select a "formular" menu formularu/kedze na stranke je podobnych viac/ do ktoreho sa ma ulozit nova premenna.
function ukazZnacky( s, formular ){
var ajaxRequest; // The variable that makes Ajax possible!
if( s.value == "" )
{
document.forms[formular]['select_znacky'].innerHTML = '<option value="">Značka vozidla</option>';
document.forms[formular]['select_modely'].innerHTML = '<option value="">Model vozidla</option>';
}
else
{
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.forms[formular]['select_znacky'].innerHTML = '<option value="">Značka vozidla</option>' +
ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "js/ukazznacky.php?druh=" + s.value, true);
ajaxRequest.send(null);
}
}