Click to See Complete Forum and Search --> : textarea = posts to page
Sux0rZh@jc0rz
08-07-2003, 11:54 PM
complete n00b here. been using the htmlgoodies.com site to learn javascript and i tell you, i dont know much. but i would like to know....how do i make textarea that when u hit enter, it will place what you said(with maximum of 55 letters) onto a part of the page without refreshing the page? you'd think it simple but i cant find it....=/ quite frustrating.:confused: :confused:
Exuro
08-08-2003, 12:41 AM
Try something 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>
innerText is IE only. I would use innerHTML (though even that is not part of the DOM... it is just very well supported proprietary code) instead.
Sux0rZh@jc0rz
08-08-2003, 11:39 AM
TY TY TY Exuro, this is exactly what i wanted! now all i have to do is fiddle with it some to make it somewhat like a chatbox....i searched the web forever trying to find a simple chatbox..(one that just did the post, and moving post upwards when new item is posted) no names or anything. i just wanna start small and build up. so thank you much.
Exuro
08-08-2003, 11:41 AM
You know... Only the person that's typing is going to be able to see the text that comes up. Other users on the website arn't going to be able to see it... You really can't make a chatroom or message board or anything like that using JavaScript. You need to use something server-side like Java, ASP, PHP, or CGI. And I didn't know innerText was IE-Only, thanks for telling me that pyro!
You're welcome. And, like I said, one should remember that by using innerHTML they are using proprietary code (though very well supported proprietary code, at that...)
Sux0rZh@jc0rz
08-08-2003, 12:02 PM
well, that sux..but at least i now know some new commands! hehe. You'll probably be hearing from me later about server-side programming if u ever visit the java forum. im a newb but thats only cause im a kid IRL (a very intuitive, intelligent kid with to much time on his hands, but a kid nonetheless)
BTW: new words for a newb, IE + DOM?? (i might have heard the full words b4 but cant remember...)
IE = Internet Explorer (http://www.microsoft.com/windows/ie/default.asp)
DOM = Document Object Model (http://www.w3c.org/DOM/)