Connecting Tech Pros Worldwide Help | Site Map

How to submit a form onblur?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 12:01 PM
Wendy S
Guest
 
Posts: n/a
Default How to submit a form onblur?

I'm trying to make sure that a form gets submitted when the person leaves
this field.

<input type="text" name="prospectNameOrId" size="50" value=""
onblur="setUserAction('Add Prospect'); document.forms[0].submit();">

In IE6, I get 'Object doesn't support this property or method'. I'm using
document.forms[0] elsewhere, and I have found examples on the web using this
syntax, so I'm not sure what the problem is. Can I not do this in onblur?

Is there a better way to do it? (I'm a Java programmer, not too experienced
in JavaScript.)

Thanks,
Wendy in Chandler, AZ




  #2  
Old July 20th, 2005, 12:01 PM
Lee
Guest
 
Posts: n/a
Default Re: How to submit a form onblur?

Wendy S said:[color=blue]
>
>I'm trying to make sure that a form gets submitted when the person leaves
>this field.[/color]

That's not really a good idea.
There are many things that can cause a field to lose focus
before the user is finished with it.

  #3  
Old July 20th, 2005, 12:01 PM
Grant Wagner
Guest
 
Posts: n/a
Default Re: How to submit a form onblur?

Wendy S wrote:
[color=blue]
> I'm trying to make sure that a form gets submitted when the person leaves
> this field.
>
> <input type="text" name="prospectNameOrId" size="50" value=""
> onblur="setUserAction('Add Prospect'); document.forms[0].submit();">
>
> In IE6, I get 'Object doesn't support this property or method'. I'm using
> document.forms[0] elsewhere, and I have found examples on the web using this
> syntax, so I'm not sure what the problem is. Can I not do this in onblur?
>
> Is there a better way to do it? (I'm a Java programmer, not too experienced
> in JavaScript.)
>
> Thanks,
> Wendy in Chandler, AZ[/color]

Either the input is not in <form></form>, or you have an input with the NAME
attribute set to "submit".

But as has already been mentioned, what you want to do is a Bad Idea. I'm on
your page, filling out my E-mail address, I get a phone call, I have to flip to
another application to get a bit of information for the caller (or any of
hundreds of other reasons that might cause focus to be lost on the input) and it
submits my incomplete E-mail address.

--
| Grant Wagner <gwagner@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html


  #4  
Old July 20th, 2005, 12:01 PM
Wendy S
Guest
 
Posts: n/a
Default Re: How to submit a form onblur?

"Grant Wagner" <gwagner@agricoreunited.com> wrote:[color=blue]
> you have an input with the NAME attribute set to "submit".[/color]

That's it! Thanks...
[color=blue]
> But as has already been mentioned, what you want to do is a Bad Idea.[/color]

Is onchange better? My users are apparently unable to click the inviting
little button to the right of this text field. The UI is a little weird,
it's not 'typical html form' since it's trying to duplicate something that
happens in a telnet app. Multivalue field

One way or another I must make sure that this form gets submitted when that
field is filled in. I'll play around with validation (in Struts) and a
hidden field and see if that works better.

Thanks,

--
Wendy in Chandler, AZ


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.