• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Remove highlight from a textbox

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
Hope i can get help for a small request.

document.formname.textboxname.select()
will highlight the text in the textbox.

How to remove the highlight programatically ??.

something like document.formname.textboxname.deselect() :-)

Is there anyway to do it ?
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try calling focus() instead of select() method.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As said already: focus() if you want th cursor to remain
or blur() if you want the cursor to not remain

Eric
 
Kishan Kumar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The issue is not about the focus here. Its about the highlight. when we issue textboxname.select() it highlights the field. If the focus is on a button, the textbox is still highlighted and if we type in characters the textbox gets updated (but onchange etc is not being fired). So onBlur of the textbox I want to programtically remove the highlight(select). As i said even if we remove the focus the highlight is still there. The highlight gets removed only if the focus shifts another textbox. If the focus shifts to a button or hyperlink, the highlight remains. So I would need a way to programatically remove the highlight.

Thanks for your help.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't want the text selected (highlighted), why are you calling select() in the first place?
 
Kishan Kumar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The scenario is like this..

I have quote and company profile as two HTML tabs
In the left frame say iam entering quote symbol in the textbox.
If I am in quote tab and hit enter the right frame opens with the quote.
I also use symbolbox.select() to have the box highlighted, so that user can type quote without using mouse and tab. This works fine since the focus and highlight remains in the symbol box.
The problem is with company profile tab, when I enter a symbol and enter, the right side frame opens with a company profile. But in this page, there is a onload which will focus to the first hyperlink in the loaded page.

So the focus is shifted from symbol box to hyperlink. But due to IE constraint the symbol is still highlighted even though focus is on hyperlink.

If the right side page opens with a onLoad to shift the focus to a hyperlink, the expectation is that the hihglight should get removed automatically, but this does not happen.

I do not know beforehand whether the right side page which loads will have a onload function or not. so when the focus is not shifting the user should have the benefit of typing symbols without mouse or tab. If the focus shifts the highlight should go off and user to has to click on the textbox to bring back the focus.
 
reply
    Bookmark Topic Watch Topic
  • New Topic