Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Submit a form action to new target ???

Posted on 2003-10-31
6
Medium Priority
?
1,523 Views
Last Modified: 2008-03-10
I have a function that sets hiddden fields in a form and submits it. The thing is I want to have the page it submits to come up in a separate window , not the same window. How do I do this???

//////////////////////////
Code sample
/////////////////////////

function submitForm(event, action, cValue, courseName){

      document.catalog.eventType.value = event;
      document.catalog.actionType.value = action;
      document.catalog.cValue.value = cValue;
      document.catalog.courseName.value = courseName;      
      document.catalog.submit();
      return false;
}
// End hiding script from old browsers -->
</script>

<br>
<div class="PageTitle">Brocade Course Catalog</div>
<br>
<FORM NAME='catalog' METHOD='POST' ACTION='http://www.brocade.com/gtms/education_services'>
<INPUT TYPE = 'HIDDEN' NAME = 'eventType' VALUE = ''>
                  <INPUT TYPE = 'HIDDEN' NAME = 'actionType' VALUE = ''>
                  <INPUT TYPE = 'HIDDEN' NAME = 'cValue' VALUE = ''>
                  <INPUT TYPE = 'HIDDEN' NAME = 'cValue1' VALUE = ''>
                  <INPUT TYPE = 'HIDDEN' NAME = 'courseName' VALUE = ''>
0
Comment
Question by:894359
[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
  • 3
  • 2
6 Comments
 
LVL 18

Assisted Solution

by:bobbit31
bobbit31 earned 800 total points
ID: 9659454
<FORM NAME='catalog' METHOD='POST' ACTION='http://www.brocade.com/gtms/education_services' TARGET=_blank>
0
 
LVL 10

Accepted Solution

by:
NetGroove earned 1200 total points
ID: 9659473
Either set in <form> tag the target:

<FORM NAME='catalog' METHOD='POST' ACTION='http://www.brocade.com/gtms/education_services'  TARGET="_new">


Or assign it in your JavaScript function:

     document.catalog.target = "_new";
     document.catalog.submit();
    return false;
}

If you have already a window, then assign to that window a name and use the name as target.


0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9659506
To assign your other window a name use this script:

<script>
window.name = "myWin";
</script>

So you can target to that window:

    document.catalog.target = "myWin";
    document.catalog.submit();
   return false;
}

Or you open a new window and give it  a name like this:

    newWin = window.open("",  "myWin", "height=100,width=100");
    document.catalog.target = "myWin";
    document.catalog.submit();
   return false;
}






0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:894359
ID: 9659542
For some reason the target="_new" in the page works but the submitting page reloads and I get an error (jsp page). I tried both methods and the both launch a new window fine but the page with the  form submission code reload?  I can't have this!
0
 

Author Comment

by:894359
ID: 9659590
I fixed it! It was because I had the funtion returning false. I just removed it!
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9659665
Thanks for the points.
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

705 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