Click to See Complete Forum and Search --> : text area = clears after submit


Sux0rZh@jc0rz
08-08-2003, 11:56 AM
Newb = me. n00b = not me. just like to say that.

I have this code (with thanx to exuro) that will have a textarea post to the page when u hit enter, it goes like this:

<html>
<head>
<script type="text/javascript">
<!--
function displayText(str) {
document.getElementById('displayArea').innerText=str;
return false;
}
//-->
</script>
</head>
<body>
<form name="form1" onSubmit="return displayText(this.text1.value);">
<input type="text" name="text1" maxlength="55" size="100" />
</form>
<br /><br />
<div id="displayArea"></div>
</body>
</html>

could anyone explain to me/show me/post the code to make the field clear after u hit enter and it posts it to the page? cause hitting delete just takes to long=P

pyro
08-08-2003, 12:04 PM
Like I said in the last thread, innerText is IE only. I would use innerHTML (or if your up for a bit more work, transverse the document object via the DOM).

Anyway, this should work for you:

<script type="text/javascript">
function displayText(str) {
document.getElementById('displayArea').innerHTML = str; //Use += if you'd rather concatenate to the text that is already there...
document.form1.text1.value = "";
return false;
}
</script>

Sux0rZh@jc0rz
08-08-2003, 12:14 PM
I know that its IE only(i assume that means only the person who posts it can read it) but being a newb the only way i could discribe what i wanted was to refur to it as a chatbox..i'll really be using it for personalizing my page by having them type their name and other information and have it post it in the text they read so that it seems more...well...personal.

pyro
08-08-2003, 05:22 PM
IE only means that it only works in the Microsoft Internet Explorer browser...