plusieurs fonctions avec onclick
Slt les développeurs!
j'ai un probleme assez bizzarre...
J'ai un bouton (créé dynamiquement) et qui, onclick=> devrait declencher
plusieurs (3) fonctions.
Mais rien de tout ca ne marche si je ne fais pas un alert apres la premiere fonction :(
voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
function callAjax(url, pageElement, callMessage, errorMessage) {
document.getElementById(pageElement).innerHTML = callMessage;
try {
req = new XMLHttpRequest();
/* e.g. Firefox */
} catch (e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
/* some versions IE */
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
/* some versions IE */
} catch (E) {
req = false;
}
}
}
req.onreadystatechange = function() {
responseAjax(pageElement, errorMessage);
};
req.open("GET", url, true);
req.send(null);
}
function responseAjax(pageElement, errorMessage) {
var output = '';
if (req.readyState == 4) {
if (req.status == 200) {
output = req.responseText;
document.getElementById(pageElement).innerHTML = output;
} else {
document.getElementById(pageElement).innerHTML = errorMessage
+ "\n" + output;
}
}
}
function loadMainContent() {
callAjax('load.php?sentAttribut=show_main_content', 'main_content',
"<img src='images/loader.gif /> Please Wait...", 'Error');
// alert('');
}
function showFieldsets()
{
if(document.getElementById('details')!=null)
document.getElementById('details').style.display = 'none';
if(document.getElementById('result')!=null)
document.getElementById('result').style.display = 'block';
}
function set_searchButton_onclick(searchAttribut)
{
this.loadMainContent();
// alert('');
this.showFieldsets();
this.loadSearchResult(searchAttribut);
}
function setSeachButton() {
// alert(document.getElementById('details'));
var searchButton = document.createElement("input");
var sel = document.getElementById('searchOption');
var searchAttribut = sel.options[sel.selectedIndex].value;
var td = document.getElementById('searchButton');
searchButton.type = "button";
searchButton.value = "Suchen";
searchButton.alt = searchAttribut;
searchButton.setAttribute('onclick', "set_searchButton_onclick(this.alt);");
while (td.hasChildNodes()) {
td.removeChild(td.firstChild);
}
td.appendChild(searchButton);
} |
MERCI pour toute aide :)