Selected text for HTMLInputElement - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Selected text for HTMLInputElement

Friends.

Is it possible at all to find the selected text of an HTMLInputElement???

Is there any known way to access it.

SOS. :((

Thanks in advance & Regards
Sanjay

Comments

  • JonathanJonathan Posts: 2,914Member
    Hi,

    : Is it possible at all to find the selected text of an
    : HTMLInputElement???
    :
    : Is there any known way to access it.

    Maybe JavaScript is the answer? I don't know JavaScript too well, but I think you'd maybe do it like:-

    var whatsinbox = document.NameOfForm.NameOfElement.value;

    What do you want to do with the data once you've accessed it?

    Jonathan




    -------------------------------------------
    Count your downloads:
    http://www.downloadcounter.com/
    And host your site:
    http://www.incrahost.com/
    Don't say I never give you anything... ;-)

  • san_kapoorsan_kapoor Posts: 3Member
    Hello pal.

    I do not want the whole value... I wish to get the "selected" text only.

    Once I have it... I will apply some application logic on it.

    Any clues.

    : Hi,
    :
    : : Is it possible at all to find the selected text of an
    : : HTMLInputElement???
    : :
    : : Is there any known way to access it.
    :
    : Maybe JavaScript is the answer? I don't know JavaScript too well, but I think you'd maybe do it like:-
    :
    : var whatsinbox = document.NameOfForm.NameOfElement.value;
    :
    : What do you want to do with the data once you've accessed it?
    :
    : Jonathan
    :
    :
    :
    :
    : -------------------------------------------
    : Count your downloads:
    : http://www.downloadcounter.com/
    : And host your site:
    : http://www.incrahost.com/
    : Don't say I never give you anything... ;-)
    :
    :

  • JonathanJonathan Posts: 2,914Member
    Hi,

    : I do not want the whole value... I wish to get the "selected" text
    : only.
    :
    : Once I have it... I will apply some application logic on it.
    :
    : Any clues.

    Hmmm...I'm not much good on JavaScript! But this seems to display the currently selected text:-

    alert(document.selection.createRange().text);

    Any good?

    Jonathan


    -------------------------------------------
    Count your downloads:
    http://www.downloadcounter.com/
    And host your site:
    http://www.incrahost.com/
    Don't say I never give you anything... ;-)

  • san_kapoorsan_kapoor Posts: 3Member
    Thats impressive....!!

    Many Thanks.

    : Hi,
    :
    : : I do not want the whole value... I wish to get the "selected" text
    : : only.
    : :
    : : Once I have it... I will apply some application logic on it.
    : :
    : : Any clues.
    :
    : Hmmm...I'm not much good on JavaScript! But this seems to display the currently selected text:-
    :
    : alert(document.selection.createRange().text);
    :
    : Any good?
    :
    : Jonathan
    :
    :
    : -------------------------------------------
    : Count your downloads:
    : http://www.downloadcounter.com/
    : And host your site:
    : http://www.incrahost.com/
    : Don't say I never give you anything... ;-)
    :
    :

Sign In or Register to comment.