Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 804
  • Last Modified:

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.
0
JoshDale
Asked:
JoshDale
  • 7
  • 6
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now