Click to See Complete Forum and Search --> : Selecting text from a LARGE block


Jefficus
09-09-2004, 05:11 PM
I tried this question in the HTML group but haven't had any responses. It occurs to me that it might be better suited to the Javascript group, so here goes...

I have a site I'm putting together that has a LARGE block of text, perhaps as long as 50,000 words.

I want to present a form to the user that allows him to select a passage from this block of text - anywhere from one word to the entire block.

But when I get the form submission, I don't want to receive the quoted text as input, I want to receive the range of word numbers. (Receiving the quoted string itself would be ambiguous, as the same sequence of words might occur several times in the block.)

Suppose the passage was "Fourscore and seven years ago today our fathers kicked some butt and took some names." If the user selects the words "ago today our", I want to recieve a form submission with the values 4,5,6 (or maybe 4-6) but not "ago today our".

I am looking for some suggestions on how to achieve this. I *COULD* just show a form with every single word and put a checkbox in front of each word. But that would be hideous.

Does anybody know a more elegant way to handle this? Should I be looking at adapting a client-side Java applet text editor? If so, any suggestions on which one? Is there a better way?

Venturing into new territory,
Jefficus

Warren86
09-09-2004, 05:39 PM
Jefficus:
Please forgive me. Are you saying that the user will drag the mouse over a certain passage, then right-click, then click Copy, then go to your form, then click Paste? If so, is it possible that two or more such "strings" would be identical?

Warren

Jefficus
09-09-2004, 05:47 PM
No, not quite. The user will be shown the entire block of text as part of the form. Then I want him to be able to select a subset of that text (still within the form). But when the form gets submitted, I don't want that whole block of text sent back, and I don't want the selected text string sent back either. I just want the index numbers indicating what part of the block was selected.

Essentially, I want to create a text area that behaves like a select box. But since formatting the text as paragraphs is important, I can't do it as an actual select box. (And with 50K words, the select menu would be a monster.)

Warren86
09-09-2004, 06:20 PM
Jefficus:
But still, the user drags the mouse to make the selection, correct? It's my understanding that, whether in JS or otherwise, I'm certain in your experience, as well, that only ONE passage of highlighted text can be made at a time. Highlight another, and the first one is no longer hightlighted. Using a 50K text block, it seems to me, that you need a "floating" button, perhaps labeled, "Send Selection." I can do that. And, putting the text within a form, may not be necessary. Do you just need to access the data that has been accumulated, or is the Submit action of a form essential? Could the data, meaning the index of the first word of the passage, and the last word of the passage, be saved to an ordinary text file? Something like this:
6,15
45,47
120,139


Warren

Jefficus
09-09-2004, 09:11 PM
Correct. The user drags to select a passage. At least, this is currently the way I envision it, simply because that's the way most selection systems work. However, the ability to select multiple passages would be useful in about 25% of the cases.

As for submission, there are other form fields that need to be submitted with the selection - I am actually creating annotation records for certain text sequences. So yes, it does need to get submitted at some point.

Now, the idea of creating a local text record of the "submission sets" would work, but I'm not sure if it buys anything unless perhaps it reduces the number of times the 50K text base needs to get reloaded into the selector control.

Jefficus