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

Text areas in html implementing using javascript

P: n/a
Hi I need help with a topic I have an html page and in it i have a
textarea which can have a multiple of info, is there any possible way
that i can out put a specific area of the textarea using javascript or
no its not possible.

Jan 24 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
<SR****@opinionsite.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi I need help with a topic I have an html page and in it i have a
textarea which can have a multiple of info, is there any possible way
that i can out put a specific area of the textarea using javascript or
no its not possible.


It's not clear what you're asking for.

Say you have:

<textarea name="ta" id="ta" cols="40" rows="10">Go Cubs!</textarea>

Are you asking how you could extract,say, just "Cubs" from it?

If so, then a few questions:

1) What do you want to extract?
Is the the same word or phrase each time?

2) What do you want to do with it?
Just store in a JavaScript variable?
Jan 24 '06 #2

P: n/a
I) its not the same text or phrase, i wish it was but its not.
2) I want to be able to pull that one word or phrase and set it to be
equal to a variable, and out put it in another location.

Please help

Feb 6 '06 #3

P: n/a
"Shamaila" <SR****@opinionsite.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I) its not the same text or phrase, i wish it was but its not.
2) I want to be able to pull that one word or phrase and set it to be
equal to a variable, and out put it in another location.

Please help


I am still having trouble understand exactly what you want to do.

Could you provide a very detailed example? You started with:

"Hi I need help with a topic I have an html page and in it i have a
textarea which can have a multiple of info, is there any possible way
that i can out put a specific area of the textarea using javascript or
no its not possible."

a) "I have an html page ..."; is it your page (or a URL)?

b) Does the page contain a <form> with a <textarea>?

c) What would determine "a specific area of the textarea"?

Is the following even close to what you want?

<html>
<head>
<title>ta.htm</title>
<script type="text/javascript">
function ta() {
var form = document.form1;
var area = form.area1.value;
if (area == "") return;
var word = "hello";
var what = area.toLowerCase();
if (what.indexOf(word) < 0) return;
alert("The word '" + word + "' is in the textarea.");
}
</script>
</head>
<body>
<form name="form1">
<textarea name="area1" cols="40" rows="8">Hello World!</textarea>
<input type="button" value="Click" onclick="ta()">
</form>
</body>
</html>
Feb 6 '06 #4

P: n/a
Hi thanx or the help, ok let me start over. I work for a marketing
research firm, we have a survey, with various questions and one of the
open-ended questions of course consists of a text area. lets say
some one entered, Bear doll candy, i want to be able to take each of
these words and somehow make them into variables so i can call on these
variables later in the survey. does that make more sense, i hope it
does.

Feb 6 '06 #5

P: n/a
"Shamaila" <SR****@opinionsite.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi thanx or the help, ok let me start over. I work for a marketing
research firm, we have a survey, with various questions and one of the
open-ended questions of course consists of a text area. lets say
some one entered, Bear doll candy, i want to be able to take each of
these words and somehow make them into variables so i can call on these
variables later in the survey. does that make more sense, i hope it
does.


Better -- but I would think you would want to do this on the server
instead of the client; if so, what technology will you use: ASP, CGI, or ?

Here's a client-side approach that may give you some ideas.

<html>
<head>
<title>ta_words.htm</title>
<script type="text/javascript">
function ta() {
var form = document.form1;
var area = form.area1.value;
if (area == "") return;
var list = area.match(/\w+/g);
var what = "Words in the textarea:";
for (var i=0; i<list.length; i++) {
what += "\n" + (i+1) + ". " + list[i];
}
alert(what);
}
</script>
</head>
<body>
<form name="form1">
<textarea name="area1" cols="40" rows="8">
I like Bear doll candy.</textarea>
<input type="button" value="Click" onclick="ta()">
</form>
</body>
</html>


Feb 6 '06 #6

P: n/a
JRS: In article <11**********************@g44g2000cwa.googlegroups .com>
, dated Mon, 6 Feb 2006 13:54:09 remote, seen in
news:comp.lang.javascript, Shamaila <SR****@opinionsite.com> posted :
Hi thanx or the help, ok let me start over. I work for a marketing
research firm, we have a survey, with various questions and one of the
open-ended questions of course consists of a text area. lets say
some one entered, Bear doll candy, i want to be able to take each of
these words and somehow make them into variables so i can call on these
variables later in the survey. does that make more sense, i hope it
does.


Let the textarea be named TA. Then

eval(TA.value.replace(/(\w+)/g, " var $1 ; "))

will do what you ask for, assuming that the words are separated by
whitespace. I don't know how you expect to use the variables, though.

Demonstration :

TA = "aaa bbb cc"
S = TA.replace(/(\w+)/g, "var $1 ; ")
// var aaa ; var bbb ; var cc ;
Or S = "var " + TA.replace(/(\w+)/g, "$1,") + " X ;"
// -> "var " + TA.replace(/(\w+)/g, "$1,") + " X ;"

where X is a dummy.
However, ISTM that you should advise your firm to employ a genuine
programmer for writing survey analysis code.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 7 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.