Click to See Complete Forum and Search --> : button.blur() How to make a button blur


jslady
04-02-2003, 01:49 PM
Please help.

I have a simple problem that i just cant sort out.

In a form, I have a text field and a button field. When someone clicks on the text field the normal behaviour is for the button to be slected.

I want to blur the button when the text field is selected.

I have tried the 2 examples below but neither works.
Any ideas?

ATTEMPT 1:

<form>
<input type="text">
<input type="submit" name="mybutton" onfocus="document.myform.mybutton.blur()";>
</form>


ATTEMPT 2:

<form>
<input type="text">
<input type="submit" onfocus="this.blur()";>
</form>

many thanks.

Jona
04-02-2003, 01:52 PM
<input type=text onfocus="this.focus()">
<input type=submit onfocus="document.forms[0].elements[0].focus()">

jslady
04-02-2003, 02:00 PM
Jona your suggesiton didnt work.

I am trying to blur the button when the form is activated. i.e. someone clicks in the text field.

I don't want the button to get selected.

Any ideas?


<html>
<head>
</head>
<body>

<form name="myform">

<input type=text onfocus="this.focus()">
<input type=submit onfocus="document.forms[0].elements[0].focus()">


</form>

</body>
</html>

Jona
04-02-2003, 02:49 PM
Maybe... <body onload="document.myForm.myField.focus();">

jslady
04-02-2003, 03:07 PM
no, no good.

why are you using .focus()?

I am trying to blur the button as i dont want it show as selected.

thanks anyway.

pfullbright
04-02-2003, 03:14 PM
Is this what you're looking for? It does more in the way of color, or fading, not a blur.

http://javascript.internet.com/buttons/fading-button.html

Jona
04-02-2003, 03:21 PM
Well you can do the opposite: <body onload="document.myForm.myButton.blur();">

jslady
04-02-2003, 03:23 PM
thanks peggy, but thats not what i need.

if you copy the code below into your editor, view it in your browser and then click in the text field, you will see that the button gains a small border, it becomes selected.

I am trying to avoid this as the button class I will be using will mean that this normal behaviour looks truly awful.

I have been trying to use .blur() method but with no success.


Please help if you can.


<html>
<head>
</head>
<body>

<form>

<input type=text>
<input type=submit>


</form>

</body>
</html>

jslady
04-03-2003, 03:12 AM
come on, someone must know the answer to this.

I am trying to blur the button when the text field is selected/ form is active.

help!!!


<html>
<head>
</head>
<body>

<form>

<input type=text>
<input type=submit>


</form>

</body>
</html>

pfullbright
04-08-2003, 06:01 PM
I hope this helps...

I found this out at http://www.cookwood.com/html5ed/ (on the top right). Then go to "Examples", then to Chapter 18, then to "Triggering a Script".

It states, in the HTML book, to replace "onclick" with "onblur". After the "onblur", type "script", where script is the actual script that should run when the event occurs.

<title>Triggering scripts</title>
</head>
<body>
<p>What <a href="time.html" onclick="alert('Today is '+ Date())">time</a> is it? </p>

<p>Here's the rest of the page.</p>
</body>
</html>