...

View Full Version : Interacting with a TextArea?



BatCountry
08-23-2007, 02:08 AM
Is it possible to interact with a textarea field:

<textarea id="list"></textarea>

I have a textarea where you can enter one item per a line, and I want to be able to get each new line in the textarea. I can't find any way with the DOM to get how many rows are in the textarea and how to know what is each row.

Anyone give a hand?

abduraooft
08-23-2007, 09:28 AM
I hope you are trying to get something like
http://www.codingforums.com/showthread.php?t=120067

Kor
08-23-2007, 12:57 PM
I guess you were looking for an end line separator ('\n')
Something like this?:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function alertLine(f){
var n=Number(f['nr'].value)-1, t=f['txa'].value.split('\n');
if(t[n]){alert(t[n])}
}
</script>
</head>
<body>
<form action="">
<textarea name="txa" id="txa"></textarea>
<br><br>
<input type="button" value="Alert the line no:" onclick="alertLine(this.form)"> <input type="text" name="nr" id="nr" size="4">
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum