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

12-22-2005, 02: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?

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

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

12-22-2005, 03: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>

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

12-22-2005, 06: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