Trying to send submit to new window

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
RichardFoxAsked:
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.

ZvonkoSystems architectCommented:
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

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
GwynforWebCommented:
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
GwynforWebCommented:
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
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.

GwynforWebCommented:
if you are using subfolders it should be    var dUrl = "Exe/yyNET.exe?query="+dQuery
0
godspropyCommented:
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
ZvonkoSystems architectCommented:
Are here too many parrots or is it simply an echo after three hours ;-)
0
GwynforWebCommented:
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
godspropyCommented:
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
RichardFoxAuthor Commented:
That's why I gave you some points, I appreciated the extra information
0
ZvonkoSystems architectCommented:
"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
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.