/    Sign up×
Community /Pin to ProfileBookmark

Selecting text on a page

Hi,

I have seen the “Select All” button or “Highlight All” button on numerous sites in the way of selecting text in a form field, but what I am wanting to do is with a button select all text in a table so all the viewer needs to do is press CRTL+C to copy the text. I have tried [B]javascript:document.MyTable.select();[/B] but it doesn’t work. It really isn’t an option for me to use a text box for the data as it is being formed dynamically in a table from a database.

Any assistance would be appreciated. (Cross-browser would be fantastic) ?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@wbportApr 13.2011 — document.tablename.[B]fieldname[/B].select() should work. Several examples are here.htm.
Copy linkTweet thisAlerts:
@pj1981authorApr 13.2011 — document.tablename.[B]fieldname[/B].select() should work. Several examples are here.htm.[/QUOTE]


Ummm... the link that you attached took me to a page about Noteworthy Composer?!?! and I'm not using a form field or a text box... Just text in a table. :-S
Copy linkTweet thisAlerts:
@wbportApr 13.2011 — Ummm... the link that you attached took me to a page about Noteworthy Composer?!?! and I'm not using a form field or a text box... Just text in a table. :-S[/QUOTE]
I don't think you can select an entire table, just individual fields. If you need more than one occurrence, do a [B]for[/B] loop to append to a string variable. [B]That[/B] can be moved to a text field to be selected like the twelve tone example.
×

Success!

Help @pj1981 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,
)...