onBlur Submit

How can I set some text input fields so that onBlur it will submit the form, but the submit has a name, similar to <input name="onBlurSubmit" type="submit">

Also, when the form is submitted, it will affect a separate iframe, so I need to set the target to PreviewPane.
JoshDaleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BatalfCommented:
Why do you need a name?

You could submit the form onsubmit like this:

<form name="myForm" action="whatever.html">
<input type="text" onblur="document.myForm.submit()">
</form>
0
knightEknightCommented:
don't forget to put the target in the form:

<form name="myForm" action="whatever.html" target="PreviewPane" >
<input type="text" name="myText" onblur="this.form.submit()" />
</form>
0
JoshDaleAuthor Commented:
well, because it is like having 2 submit buttons. One will take action and go to one page the other will go to the other page.

I am creating a form where I can write css right into the form. I also have a iframe that I would like to preview what I did every time I go to another field.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JoshDaleAuthor Commented:
Actually, now that I think about it, it doesn't need to have a name. But it does have to affect a different iframe than the form will on normal submit.
0
BatalfCommented:
You could modify the action before you submit

<input type="text" onsubmit="document.formName.action='page.html';document.form1.submit()">

and set a different action for other onblur

Batalf
0
BatalfCommented:
or you could change the target attribute.
0
JoshDaleAuthor Commented:
an example would be

<form method="post" action="act_Dothis.htm">
<input type="text" onBlur="dothis"> <-- onBlur, submit to the iframe named "PreviewPane"
<input name="Submit" type="submit" value="Submit"> <-- onClick, submit the form
</form>
0
BatalfCommented:
Try

<input type="text" onBlur="document.forms[0].target='nameOfIframe';document.forms[0].submit()">
0
BatalfCommented:
Larger example:

<form method="post" action="page.html">
<input type="text" onchange="document.forms[0].target='myIframe';document.forms[0].submit()">
<input type="text" onchange="document.forms[0].target='secondIframe';document.forms[0].submit()">
</form>
<iframe name="myIframe" width="200" height="200" src="page.html"></iframe>
<iframe name="secondIframe" width="200" height="200" src="page.html"></iframe>
0
JoshDaleAuthor Commented:
ok, can I specify what page to take action to in the onBlur?
0
JoshDaleAuthor Commented:
like right now, it will submit to page.html, can the onBlur action submit to dsp_Preview.cfm
0
BatalfCommented:
Yes, you can. set a new value of the action property.

<form method="post" action="page.html">
<input type="text" onchange="document.forms[0].action='newPage.html';document.forms[0].target='myIframe';document.forms[0].submit()">
<input type="text" onchange="document.forms[0].action='newPage2.html';document.forms[0].target='secondIframe';document.forms[0].submit()">
</form>
<iframe name="myIframe" width="200" height="200" src="page.html"></iframe>
<iframe name="secondIframe" width="200" height="200" src="page.html"></iframe>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoshDaleAuthor Commented:
Awsome, you da man chief.

I turned it into a function so it is less ugly, but that is exactly it. Thanks

<script type="text/javascript">
<!--
function SubmitForm(){
      document.StyleForm.action='../DisplayStyles/dsp_Preview.cfm';
      document.StyleForm.target='PreviewWindow';
      document.StyleForm.submit()
}
//-->
</script>
0
BatalfCommented:
Glad I could help!

Thanks for the "A"

Batalf
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.