|
 |
javascript thread: Re: using onBlur, on Focus events, more than one text box
Message #1 by google s <googlesxyz@y...> on Tue, 14 Aug 2001 05:27:55 -0700 (PDT)
|
|
inside a javascript event function, you can get the object on the page
caused the event by accessing "event.srcElement". There is another way I
used to do it by passing in the textboxes name in as a parameter, such as
HandleBlur(text1), and then in the function you can access it like...
function HandleBlue(whichbox) {
eval(whichbox).bgColor = ????;
};
but I'm sure the event.srcElement object is a better way to go...
> Thanks for your help. It's working fine.
>
> But, I want to call this events through common
> function.
>
> So, I can use this function more than one place.
>
> could you help me if i want to use this function more
> than one text box.
>
> here is my script follows:
>
> <script language="javascript">
> function lostfocus()
> {
> document.frm.text2.style.background='white'
>
> document.frm.text2.style.color='black'
> }
>
> function setfocus()
> {
>
> document.frm.text2.style.background='blue';
> document.frm.text2.style.color='black'
>
>
> }
>
> </script>
>
> </HEAD>
> <BODY>
> <form name=frm>
>
> <INPUT type="text" id=text2 name=text2
> onfocus="setfocus()" onBlur="lostfocus()">
> <INPUT type="text" id=text3 name=text3>
> <P> </P>
> <INPUT type="submit" value="Submit" id=submit1
> name=submit1>
>
> <INPUT type="reset" value="Reset" id=reset1
> name=reset1>
>
> </form>
> </BODY>
>
> Could you please help me if anybody knows.
>
> Thanks for all your cooperation.
>
>
>
> --- "Johnson, Israel" <IJohnson@R...> wrote:
> > you would need to use: style.background
> > 'backgroundColor?'. Tie this to
> > the event handlers onblur on focus.
> > Example: onfocus="style.background
> > 'white';style.color='blue'"
> > onblur="style.background
> > 'blue';style.color='white'"
> >
> > -----Original Message-----
> > From: google s [mailto:googlesxyz@y...]
> > Sent: Monday, August 13, 2001 9:00 AM
> > To: javascript
> > Subject: [javascript] Re: onBlur, on Focus events
> >
> >
> > Hello Everybody,
> >
> > I need help on using onBlur and onfocus
> > events in Input tags.
> >
> > This is for <Input type=text> validations.
> >
> > Changing the background color depending on gain
> > focus
> > and lost focus.
> >
> > ex: I have more than one text box. I have to use two
> > functions for onblur and onfocus events.
> >
> > When the user try to enter the information in
> > textbox
> > give focus and change the background color. When the
> > cursor move to next text box, give focus to this box
> > and give onblur event for previous box and change
> > the
> > background.
> >
> >
> > If you could please help me out, that would be
> > great.
> >
> > Thanks for all your cooperation.
|
|
 |