By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

div to textarea

P: n/a
Hi, I want to transform <divand </divinto <textareaand
</textareawith the click of a button, making the text inside
editable... any ideas how I might do this?

Sep 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Mark" <mn*******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi, I want to transform <divand </divinto <textareaand
</textareawith the click of a button, making the text inside
editable... any ideas how I might do this?
Will this help? Watch for word-wrap. Test as-is.

<html>
<head>
<title>div2text.htm</title>
<script type="text/javascript">
var bool = true;
function edit() {
var text;
if (bool) {
bool = false;
text = document.getElementById("text").innerHTML;
document.getElementById("text").style.display = "none";
document.getElementById("area").style.display = "block";
document.getElementById("area").value = text;
} else {
bool = true;
text = document.getElementById("area").value;
document.getElementById("area").style.display = "none";
document.getElementById("text").style.display = "block";
document.getElementById("text").innerHTML = text;
}
}
</script>
</head>
<body>
<div id="text" style="border:solid 1px black">Hello World</div>
<form>
<textarea id="area" rows="2" cols="30"
style="display:none"></textarea>
<input type="button" value="Click" onclick="edit()">
</form>
</body>
</html>
Sep 6 '06 #2

P: n/a

McKirahan wrote:
"Mark" <mn*******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi, I want to transform <divand </divinto <textareaand
</textareawith the click of a button, making the text inside
editable... any ideas how I might do this?

Will this help? Watch for word-wrap. Test as-is.

<html>
<head>
<title>div2text.htm</title>
<script type="text/javascript">
var bool = true;
function edit() {
var text;
if (bool) {
bool = false;
text = document.getElementById("text").innerHTML;
document.getElementById("text").style.display = "none";
document.getElementById("area").style.display = "block";
document.getElementById("area").value = text;
} else {
bool = true;
text = document.getElementById("area").value;
document.getElementById("area").style.display = "none";
document.getElementById("text").style.display = "block";
document.getElementById("text").innerHTML = text;
}
}
</script>
</head>
<body>
<div id="text" style="border:solid 1px black">Hello World</div>
<form>
<textarea id="area" rows="2" cols="30"
style="display:none"></textarea>
<input type="button" value="Click" onclick="edit()">
</form>
</body>
</html>
yeah... sure, that looks like it will work. thank you for writing this
all out for me!
i thought there mighty be a nifty way where you could just change the
type of element, and not have to have two seperate things with the same
content, but I guess not. oh well! not like it's a big loss.

Sep 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.