Anyway to get the the selected text with Javascript

  •  09-15-2005, 1:39 PM

    Anyway to get the the selected text with Javascript

    I am trying to have a user enter an ISBN and then select it and then I do some remote scripting so I can popluate the editor with book data for the isbn.

    This line of javascript is failing in both IE and Netscape/Firefox

          if (e.setSelectionRange) {    
             strText = e.value.substring(e.selectionStart, e.selectionEnd);
          }
          else {
             strText = document.selection.createRange().text;

           }

    This works with a simple textarea html forms control

    Thanks
View Complete Thread