HighDots Forums  

List <a> tags in a textarea

Javascript JavaScript language (comp.lang.javascript)


Discuss List <a> tags in a textarea in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
just1coder
 
Posts: n/a

Default List <a> tags in a textarea - 05-10-2004 , 05:39 PM






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

Reply With Quote
  #2  
Old   
Randy Webb
 
Posts: n/a

Default Re: List <a> tags in a textarea - 05-10-2004 , 05:48 PM






just1coder wrote:
Quote:
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.

Quote:
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/


Reply With Quote
  #3  
Old   
just1coder
 
Posts: n/a

Default Re: List <a> tags in a textarea - 05-11-2004 , 09:12 AM



Randy Webb <hikksnotathome (AT) aol (DOT) com> wrote

Quote:
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.


Reply With Quote
  #4  
Old   
Lasse Reichstein Nielsen
 
Posts: n/a

Default Re: List <a> tags in a textarea - 05-11-2004 , 12:04 PM



just1coder (AT) yahoo (DOT) ca (just1coder) writes:

Quote:
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'?

....
Quote:
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 - lrn (AT) hotpop (DOT) com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'


Reply With Quote
  #5  
Old   
Randy Webb
 
Posts: n/a

Default Re: List <a> tags in a textarea - 05-11-2004 , 12:31 PM



just1coder wrote:

Quote:
Randy Webb <hikksnotathome (AT) aol (DOT) com> wrote


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/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.