?
Solved

onBlur Submit

Posted on 2005-02-25
14
Medium Priority
?
780 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:JoshDale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
14 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13408008
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
 
LVL 33

Expert Comment

by:knightEknight
ID: 13408026
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
 

Author Comment

by:JoshDale
ID: 13408029
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:JoshDale
ID: 13408033
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
 
LVL 32

Expert Comment

by:Batalf
ID: 13408043
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
 
LVL 32

Expert Comment

by:Batalf
ID: 13408045
or you could change the target attribute.
0
 

Author Comment

by:JoshDale
ID: 13408049
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
 
LVL 32

Expert Comment

by:Batalf
ID: 13408068
Try

<input type="text" onBlur="document.forms[0].target='nameOfIframe';document.forms[0].submit()">
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13408089
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
 

Author Comment

by:JoshDale
ID: 13408106
ok, can I specify what page to take action to in the onBlur?
0
 

Author Comment

by:JoshDale
ID: 13408112
like right now, it will submit to page.html, can the onBlur action submit to dsp_Preview.cfm
0
 
LVL 32

Accepted Solution

by:
Batalf earned 2000 total points
ID: 13408115
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
 

Author Comment

by:JoshDale
ID: 13408130
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
 
LVL 32

Expert Comment

by:Batalf
ID: 13408134
Glad I could help!

Thanks for the "A"

Batalf
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question