Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  132] [ 7]  / answers: 1 / hits: 26552  / 13 Years ago, sat, march 26, 2011, 12:00:00

I just came across a situation in which it would be an elegant solution to have only portions of a text area (previously loaded with text) be editable while other portions are not (greyed out, so to speak).



Is this possible at all by using javascript in general?



I would be using jQuery.


More From » jquery

 Answers
46

After searching find it's really hard to make a text area partially editable




Here is my code that i used for this requirement





input
{
width:100%;
border:0px solid;
outline:none
}


<!DOCTYPE html>
<html>
<div style=padding: 2px;border:1px solid #ccc;width: 82%;max-height:100px;min-height: 51px;overflow:auto;outline: none;resize: both; contenteditable=true unselectable=on>


<input placeholder=enter prefix... value=editable postfix... ></input>
<div id='unEditable' style=background-color:yellow;width: fit-content;padding-left:10px;padding-right:10px;border-radius:10px;height: fit-content; contenteditable=false unselectable=off onkeyup= >
fixed content non-editable

</div>
<input placeholder=enter postfix... value=editable prefix... style='width:97%'></input>

</div>
</html>




[#93060] Thursday, March 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
judydestiniem

Total Points: 215
Total Questions: 109
Total Answers: 86

Location: Indonesia
Member since Wed, Jul 7, 2021
3 Years ago
;