Besoin de correction sur mon script

Bonjour,
J'aurais besoin d'aide afin de corriger le script suivant voir de l'améliorer.
Ce script lit un textarea (dont l'id est content)
Il test si il y à des codes HTML d'images et si oui il me met les différents paramètre (src, alt, align...) dans des variables.
Et à la fin, j'ai mit des alert juste pour tester qu'il me renvoi bien les bonnes infos
Le but final, est d'utiliser ses variable afin d'auto-compléter un formulaire.

function editimg()
	{
			$a = document.getElementById('content').value;
			var resultat = $a.match(/<(img[^>]*)>/g);
			for (i in resultat) { 
			
				var src[i] = $resultat[i].test(/(src="[^"]*)"/g);
				
				if (src[i] = true){
				var temp1 = src[i].match(/([^"]*)/g);
				var finsrc[i] = temp1[3];
				}
				
				var alt[i] = $resultat[i].test(/(alt="[^"]*)"/g);
				
				if (alt[i] = true){
				var temp2 = alt[i].match(/([^"]*)/g);
				var finalt[i] = temp2[3];
				}
				
				var align[i] = $resultat[i].test(/(align="[^"]*)"/g);
				
				if (align[i] = true){
				var temp3 = align[i].match(/([^"]*)/g);
				var finalign[i] = temp3[3];
				}
				
				var width[i] = $resultat[i].test(/(width="[^"]*)"/g);
				
				if (width[i] = true){
				var temp4 = width[i].match(/([^"]*)/g);
				var finwidth[i] = temp4[3];
				}
				
				var height[i] = $resultat[i].test(/(height="[^"]*)"/g);
				
				if (height[i] = true){
				var temp5 = height[i].match(/([^"]*)/g);
				var finheight[i] = temp5[3];
				
				alert('src' + i + ' : ' + finsrc[i]); 
				alert('alt' + i + ' : ' + finalt[i]); 
				alert('align' + i + ' : ' + finalign[i]); 
				alert('width' + i + ' : ' + finwidth[i]); 
				alert('height' + i + ' : ' + finheight[i]); 
				}	
			} 
	}


Merci d'avance pour votre aide
Cordialement.
Configuration: Mac OS X
Firefox 3.5.1

1 réponse

  1. Dans tous tes if, tu fais un =
    = sers à l'affectation, pas à la comparaison

    remplaces tes = par ==