Hi people,

I'm currently developing a simple comments system and I'm trying to create a "Edit in Place" fuction to people fastly edit their messages...

It should be similar to what happens with fast edit options on vBulletion (this one) or IPB.

My currently JS code is:

Code:
// Edit in Place
// Por Fazedor de Site
 
function removeForm(){
		$id("form_altera").parentNode.removeChild($id("form_altera"));
}
/*function setAttributeIE(node, name, value) {
	var i;
	for (i = 0; i {	if (node.attributes[ i ].type == type){ node.attributes[ i ].type = value; }	}
}*/
function mostra(){	
	
	if(!$id("form_altera")){
		
		$id("editinplace").style.display='none';
 
		
		$obj.create("span","formulario",$id("editinplace").parentNode);
 
		
		$obj.create("form","form_altera",$id("formulario"));
		
		$id("form_altera").setAttribute("name","form_altera");
		$id("form_altera").onsubmit = function(){
			$id("editinplace").style.display="";
			effects.fade(null,"editinplace",0,100);
			fsAjax("altera.php","editinplace","Loading","POST","form_altera",1,"removeForm()")
			return false;
		}
 
		
		$obj.create("input","valor",$id("formulario").firstChild);	
		
		$id("valor").setAttribute("name","valor");
		$id("valor").setAttribute("type","text");
		$id("valor").style.width='300px';
		
		$id("valor").setAttribute("value",$id("editinplace").innerHTML);
 
		
		$obj.create("br",null,$id("formulario").firstChild);	
 
		$obj.create("input","enviar",$id("formulario").firstChild,"submit");	
		
		$id("enviar").setAttribute("name","Alterar");
		$id("enviar").setAttribute("value","Alterar");
	}
}
function editar(){
	
	$id("editinplace").onclick = function(){
		
		effects.fade(null,"editinplace",100,0,"mostra()");
	}
	
	$id("editinplace").onmouseover = function(){
		this.style.background = "#EDF4FC";
		this.style.cursor = "pointer";
	}
	
	$id("editinplace").onmouseout = function(){
		this.style.background = "";
		this.style.cursor = "";
	}
 
}
addEvent(window,"load",inicia);

It works ok... but just for the first comment!

It is defined to work with, for example, <span id = "editinplace"> editable text </span>

Otherwise, each comment uses it unique ID...

So, basically it is necessary change it... I have thought in something like this, to get the function by ID:

Code:
function edit(id_post){
	$id(id_post).onclick = function(){
	effects.fade(null,id_post,100,0,"mostra()");
	}
But, only this, doesnt works.. (naturally) and my Javascript knowns are so limited, because I just began it some days ago.

Any suggestion?

Thanks