473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Text areas in html implementing using javascript

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
6 1630
<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
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
"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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ed Suominen | last post by:
I'm thinking of implementing a real-time collaborative text editor in Python using Twisted. An initial plan is to use a Twisted PB server daemon that accepts user:password:file connections from...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
0
by: Rare Book School | last post by:
RARE BOOK SCHOOL 2005 Rare Book School is pleased to announce its schedule of courses for 2005, including sessions at the University of Virginia, the Walters Art Museum/Johns Hopkins University...
4
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person...
18
by: ~john | last post by:
Sorry if this is a dumb question buy my CSS is pretty bad... but how do I get text to center vertically within a div tag? Here's my code below... the text is displaying on the far top-right. I...
3
by: brian.turner | last post by:
This is sort of a design/javascript question. It involves CSS rendering in dynamic areas of a page using IE. E 6 & 7 HI There, We've created some example static html pages (using CSS) that...
6
by: David Stone | last post by:
I have a simple question about the alt content of area elements within an image map: is it redundant to include phrases such as "link to..." or "jump to..."? My initial thought is 'yes', since...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.