Solved

Submit a form action to new target ???

Posted on 2003-10-31
6
1,514 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
  • 3
  • 2
6 Comments
 
LVL 18

Assisted Solution

by:bobbit31
bobbit31 earned 200 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 300 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now