11548 sujets

JavaScript, DOM et API Web HTML5

Bonjour,
Mon petit script suivant marche super sous safari comme sous firefox.
En revanche, sous ie 8, c'est la mort.

l'idée du script :
C'est un agenda avec des actions en retard et des actions à faire. A chaque action est associée une checkbox.
Quand une action en retard est checkée, on l'a valide dans la bdd et on ne l'affiche plus;
Quand une action dans les temps est checkée, on l'a valide dans la bdd et on la barre à l'affichage
Quand une action dans les temps est décheckée, on l'a dévalide dans la bdd et on la débarre à l'affichage

Donc l'idée du script, on commence par regarder si l'action est checkée ou non, puis si elle est en retard ou non.

function modifieritem(id,idappel){
var	$valeur= $('#tableau_agenda_rub input[id="checkbox' + id + '"]').attr('value');
	
	if ($valeur=='off'){
		
												// on test si l'action est en retard, si elle l'est, on ne l'affiche plus
											var	$retard= $('#tableau_agenda_rub td[id="retard' + id + '"]').html();
												
												// si elle n'est pas en retard, on la valide
																if($retard==''){
																			
																				$('#tableau_agenda_rub td[id="tdcheckbox' + id + '"]').empty();
																				$('#tableau_agenda_rub td[id="tdcheckbox' + id + '"]').prepend('<input type="checkbox" id="checkbox'+ id +'" onchange="modifieritem('+ id +','+ idappel+')" checked value="on">');
																				
																				
																				$.ajax({
																							type: 'GET',
																							url: "script-evenement.php",
																							cache: false,
																							data: {idvalider:id},
																							success: function(response) { $('#tableau_agenda_rub td[id="description' + id + '"]').css({ 'textDecoration': 'line-through',});
																												},
																							error: function(xhr, type, exception) { alert("Error: " + type); }
																						})
																		
																				ajout_un_pourcentage(idappel);
																	
																	
																				}
																
												
												
												
																//si elle est en retard
																	else{
																	
																	$('#tableau_agenda_rub tr[id="ligneagenda' + id + '"] td').css({
																												'backgroundImage': 'none',
																												'backgroundColor': 'white',
																											});
												
																	$('#tableau_agenda_rub tr[id="ligneagenda' + id + '"] td').animate({
																													'backgroundColor': '#090',
																													'color': '#FFF'
																												}, 1000);
																		
																	
																	$.ajax({
																	
																	
																							type: 'GET',
																							url: "script-evenement.php",
																							cache: false,
																							data: {idvalider:id},
																							success: function(response) { 
																							
																							$('#tableau_agenda_rub tr[id="ligneagenda' + id + '"] td').fadeTo("slow", 0, function(){  
																							$(this).hide();});
																												},
																							error: function(xhr, type, exception) { alert("Error: " + type); }
																						})
																	
																	
																	
																	
																	soust_total_pourcentage(idappel);
																	}
				
						
						}
					
					
					// si l'action etait valider mais que en fait non, on s'est trompé, alors on la dévalide
					else{
						$('#tableau_agenda_rub td[id="tdcheckbox' + id + '"]').empty();
						$('#tableau_agenda_rub td[id="tdcheckbox' + id + '"]').prepend('<input type="checkbox" id="checkbox'+ id +'" onchange="modifieritem('+ id +','+ idappel+')"  value="off">');
						$.ajax({
								type: 'GET',
								url: "script-evenement.php",
								cache: false,
								data: {iddevalider:id},
								success: function(response) { $('#tableau_agenda_rub td[id="description' + id + '"]').css({ 'textDecoration': 'none',
																				  																					
																					});
															},
								error: function(xhr, type, exception) { alert("Error: " + type); }
								})
						soust_un_pourcentage(idappel);
						
						

						
						}
	
	}



jquery 1.4.2

Si vous avez des idées, merci beaucoup de votre aide