If I understand correctly, you have a form in which you have a text field whose data type you've set to be rich text (XHTML) and you're wanting to put buttons on the form which let the user format the current selection in that text field in order to make the selection bold, italic and/or underlined.
Unfortunately, I don't believe this is possible. JavaScript on its own doesn't provide an object which represents the current selection. If such an object exists, it's because it's implemented by the target client (like in HTML -- the client being the browser in this case -- where I believe you have access to a
document.selection object which you can use to modify the selected text). Since neither XFA nor Acrobat expose an object which gives you access to the selection, you can't do anything with it.
Fortunately, Acrobat has a built-in text formatting toolbar which will do essentially what you're trying to achieve with your request. You can access it by selecting text in a rich text field (set the text field's Field Format to
Rich Text and its Data Format to
XHTML using the Object palette) and then pressing "Ctrl + E". This will open the text formatting toolbar with buttons for setting bold, italic, underline, strike-through, super script, font type, size, etc., and even paragraph alignment settings!
Stefan
Adobe Systems