...

View Full Version : writing a function to change a div to a textarea and back



emehrkay
12-22-2005, 03:35 AM
im having trouble with the and back part. you cant use an onblur event on a div so i put it on the text area, it doesnt work.



function divToText(eyeD,value,action){
if(action == "show"){
document.getElementById(eyeD).innerHTML = '<input type="text" name="'+eyeD+'" id="'+eyeD+'_field" value ="'+value+'" onblur="divToText('+eyeD+','+value+',"hide");" />';
}else if(action == "hide"){
document.getElementById(eyeD).innerHTML = value;
}
}


do you see any problems?
thanks

emehrkay
12-22-2005, 04:07 AM
ok my onblur was wrong i made the correct changes, still noting

onblur="divToText(\''+eyeD+'\',\''+value+'\',\'hide\');" />';

emehrkay
12-22-2005, 04:43 AM
its pretty erratic. the onblur to work, you have to click back and forth between the fields. here is how im calling it


<div id="email" onclick="divToText(this.id,'<?=$row['email'];?>','show');"><?=$row['email'];?></div>

emehrkay
12-22-2005, 05:25 PM
i think it isnt the function, onblur just wont work for this text field. any reason why?

emehrkay
12-22-2005, 07:16 PM
i figured out the problem; the onclick on the div would keep rewriting the text area because it was inside of the div. i added an error array and now i check to see if the div's id is in that array before i write it to the array



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum