List <a> tags in a textarea

J

just1coder

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
 
R

Randy Webb

just1coder said:
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.
 
L

Lasse Reichstein Nielsen

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!="") {
select.options[select.options.length]=new Option(lines);
}
}
 
R

Randy Webb

just1coder said:
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/default.asp?url=/library/en-us/jscript7/html/jsmthsplit.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsmthlastindexof.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsmthindexof.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsmthsubstring.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........
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top