?
Solved

Trying to send submit to new window

Posted on 2004-11-16
10
Medium Priority
?
799 Views
Last Modified: 2012-08-14
function SearchInDocument()
{
      var dQuery = new String();
      var dUrl = new String();
      dQuery = SearchForm.Query.value;
      if (dQuery.length > 0)
      {
            dUrl = "/Exe/yyNET.exe?query="+dQuery
            location.href = dUrl;
      }      
}


<form name="SearchForm"  target="_blank">
     <td><input type="text" name="Query" onkeypress='InterceptEnter()' class="default_border"></td>
     <td><input type="button" style="font-size: 8pt" name="SubmitQ"
                               value="Search document" onClick="SearchInDocument()" class="search_button"></td>
</form>

By entering target="_blank" in the form I had hoped to open the url in a new window, but it just displays in the current one. What am I missing?

Thanks
0
Comment
Question by:RichardFox
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 1400 total points
ID: 12597132
The <form> target is only for form submit, not for window.location change.
Open a new window.
Like this:

function SearchInDocument(){
     var dQuery = document.SearchForm.Query.value;
     if (dQuery.length > 0){
          var dUrl = "/Exe/yyNET.exe?query="+dQuery
          qW = window.open(dUrl, "Query", "top=100,left=100,height=400,width=600");
          qW.focus();
     }    
}

0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 12597142
this

<script>
function SearchInDocument()
{
     var dQuery = new String();
     var dUrl = new String();
     dQuery = SearchForm.Query.value;
     if (dQuery.length > 0)
     {
          dUrl = "/Exe/yyNET.exe?query="+dQuery
          location.href = dUrl;
     }    
}

</script> </p>

<form name="SearchForm" target="blank">
  <table>
    <tr>
      <td><input type="text" name="Query" onkeypress="InterceptEnter()" class="default_border"></td>
      <td><input type="button" style="font-size: 8pt" name="SubmitQ" value="Search document"
      onClick="SearchInDocument()" class="search_button"></td>
      <td><input type="submit"> </td>
    </tr>
  </table>
</form>
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 12597209
ah I misread the question

<script>
function SearchInDocument()
{
     var dQuery = new String();
     var dUrl = new String();
     dQuery = SearchForm.Query.value;
     if (dQuery.length > 0)
     {
          document.SearchForm.action= "/Exe/yyNET.exe?query="+dQuery
          document.SearchForm.submit()
     }  
 
}

</script>

<form name="SearchForm" target="blank">
  <table>
    <tr>
      <td><input type="text" name="Query" onkeypress="onkeypress='InterceptEnter()'" class="default_border"></td>
      <td><input type="button" style="font-size: 8pt" name="SubmitQ" value="Search document"  onClick="SearchInDocument()" class="search_button"></td>
    </tr>
  </table>
</form>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 31

Expert Comment

by:GwynforWeb
ID: 12597352
if you are using subfolders it should be    var dUrl = "Exe/yyNET.exe?query="+dQuery
0
 
LVL 2

Assisted Solution

by:godspropy
godspropy earned 200 total points
ID: 12598917
The reason the form was not submitting to "_blank" was that you were not submitting the form. <input type=button> does not submit the form. Either <input type=submit> or calling document.form.submit() would submit the form and use the "_blank" target. It looks like using window.open with the generated url will work for you. However, if you want the form to submit. Just use <input type=submit> or call document.form.submit(). In the latter, you should name the form (or give it an id).

<script>...
document.myform.submit()
...</script>

<form name=myform target="_blank">
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 12598991
Are here too many parrots or is it simply an echo after three hours ;-)
0
 
LVL 31

Assisted Solution

by:GwynforWeb
GwynforWeb earned 400 total points
ID: 12599160
I have  just reread what I wrote and it it should be

<script>
function SearchInDocument()
{
     if (dQuery.length > 0)
     {
          document.SearchForm.action= "/Exe/yyNET.exe
          document.SearchForm.submit()
     }  
}

</script>

<form name="SearchForm" target="blank">
  <table>
    <tr>
      <td><input type="text" name="Query" onkeypress="onkeypress='InterceptEnter()'" class="default_border"></td>
      <td><input type="button" style="font-size: 8pt" name="SubmitQ" value="Search document"  onClick="SearchInDocument()" class="search_button"></td>
    </tr>
  </table>
</form>
0
 
LVL 2

Expert Comment

by:godspropy
ID: 12605412
Zvonko: Parrots?

Actually, your first post was not submitting the form at all. And, GwynforWeb's post used a function to include the values in the action of the form and then submit the form, which is unnecessary. When a form is submitted it ignores anything following the ? of the action. Also, none of the other posts described why he was having a problem or how their solution would help. I just wanted to teach him to fish.
0
 

Author Comment

by:RichardFox
ID: 12605450
That's why I gave you some points, I appreciated the extra information
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 12609443
"When a form is submitted it ignores anything following the ? of the action." is simply wrong.

And I have nothing against explanation, but parts of explanation which confirm the already stated should be stating as confirmation, not as some new statement.

Anyway, everything that does help the questioner is welcome.
My offending "Parrot" statement did not help the questioner. Sorry for that :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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

569 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