Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts

    writing a function to change a div to a textarea and back

    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.

    Code:
    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

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ok my onblur was wrong i made the correct changes, still noting

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

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts
    its pretty erratic. the onblur to work, you have to click back and forth between the fields. here is how im calling it
    Code:
    <div id="email" onclick="divToText(this.id,'<?=$row['email'];?>','show');"><?=$row['email'];?></div>

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts
    i think it isnt the function, onblur just wont work for this text field. any reason why?

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •