469,927 Members | 1,763 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

List <a> tags in a textarea

Is it possible to create a dropdown list populated by the contents of a textarea?

<textarea>
<a name="this">this</a>
<a name="that">that</a>
</textarea>

Then, the dropdown would have the <a> values as options...

Please reply to

just1coder -at- yahoo -dot- ca
Jul 23 '05 #1
4 1174
just1coder wrote:
Is it possible to create a dropdown list populated by the contents of a textarea?

<textarea>
<a name="this">this</a>
<a name="that">that</a>
</textarea>

Then, the dropdown would have the <a> values as options...
Sure.
Please reply to

just1coder -at- yahoo -dot- ca


No thanks. Ask in News, get answered in News.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
Randy Webb <hi************@aol.com> wrote in message news:<-b********************@comcast.com>...
just1coder wrote:
Is it possible to create a dropdown list populated by the contents of a textarea?

<textarea>
<a name="this">this</a>
<a name="that">that</a>
</textarea>

Then, the dropdown would have the <a> values as options...


Sure.
Please reply to

just1coder -at- yahoo -dot- ca


No thanks. Ask in News, get answered in News.


I was looking for an example.
Jul 23 '05 #3
ju********@yahoo.ca (just1coder) writes:
> Is it possible to create a dropdown list populated by the
> contents of a textarea?
>
> <textarea>
> <a name="this">this</a>
> <a name="that">that</a>
> </textarea>
>
> Then, the dropdown would have the <a> values as options...

How? Should the option's value/text be '<a name="this">this</a>' or
should it be 'this'?

.... I was looking for an example.

---
var text = document.getElementById("textAreaId").value;
var select = document.getElementById("selectId");
var lines = text.split("\n");
for (var i in lines) {
if (lines[i]!="") {
select.options[select.options.length]=new Option(lines[i]);
}
}
---
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
just1coder wrote:
Randy Webb <hi************@aol.com> wrote in message news:<-b********************@comcast.com>...
just1coder wrote:
Is it possible to create a dropdown list populated by the contents of a textarea?

<textarea>
<a name="this">this</a>
<a name="that">that</a>
</textarea>

Then, the dropdown would have the <a> values as options...


Sure.

I was looking for an example.


Not what you asked, but ok.

Assuming that your textarea will *Always* be formatted in that format,
its simply a matter of getting the name and the text. I think you wanted
href= instead of name= though.

Some hints:

get the .value of the textarea, and then parse it for the name(href) and
the text.
http://msdn.microsoft.com/library/de...jsmthsplit.asp
http://msdn.microsoft.com/library/de...astindexof.asp
http://msdn.microsoft.com/library/de...mthindexof.asp
http://msdn.microsoft.com/library/de...hsubstring.asp

Split the .value of the textarea.
Now, you get the indexOf the ", the last indexOf the ", and the
substring, that will give you the href/name.
Then, you repeat for indexOf >, then the lastIndexOf <, then the
substring will give you the text.

That will give you a pretty good start, some good reading, and some
practice. Post back with your best effort........
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Donald Firesmith | last post: by
17 posts views Thread by Albert Wagner | last post: by
8 posts views Thread by ASP Yaboh | last post: by
7 posts views Thread by Andrew Robinson | last post: by
3 posts views Thread by ajay2552 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.