/    Sign up×
Community /Pin to ProfileBookmark

Ordered list in TextArea

Hello,
I would like to create an ordered list in a text area named textfield. Every time someone clicks on a link, I’d like it to add the link name to textfield1 in an ordered list. i.e. A) ? C) D)

[CODE]
function addMsg(text,element_id) {

document.getElementById(element_id).value += text + ‘n’;

}
[/CODE]

[code=html]
<A HREF=”#” onclick=”addMsg(‘You clicked on Link1′,’textfield’); return false;”>Click on Link 1</A>[/code]

For example, if you “Click on Link 1” 5 times, it will add this to the text area:

A) You clicked on Link1
? You clicked on Link1
C) You clicked on Link1
D) You clicked on Link1
E) You clicked on Link1

Then, if you deleted line C), it will automatically relabel to:

A) You clicked on Link1
? You clicked on Link1
C) You clicked on Link1
D) You clicked on Link1

Then, if you “Click on Link 1” again, the text area will again show

A) You clicked on Link1
? You clicked on Link1
C) You clicked on Link1
D) You clicked on Link1
E) You clicked on Link1

Is this possible?

The reason I want to do it is because I want users to be able to edit the text within the textarea, and copy and paste easily. Otherwise a list box would make more sense. Can’t do HTML in a textarea.. though?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@wbportMar 03.2010 — I think you need to read and recreate your textarea each time the user clicks; it's what I had to do twice in the last month, including this example.

This next website allows users to either create twelve random notes (Click) or do something different with the notes already in the textarea or pasted in there (Read): ttr.htm. It's output is preselected to be copied to the clipboard and taken to a music notation program.
Copy linkTweet thisAlerts:
@KorMar 03.2010 — 

Is this possible?[/QUOTE]

Yes. Important question: Is it your textarea empty onload?
Copy linkTweet thisAlerts:
@KorMar 03.2010 — Yes. It is possible. Important question: Is it your textarea empty onload?
Can't do HTML in a textarea.. though?[/quote]
I guess you can. But, for security reasons it is better not to, in case you want to pass data to a Data Base
×

Success!

Help @goombamd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...