Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag for United States of America

asked on

Submit a form action to new target ???

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 = ''>
SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NetGroove
NetGroove

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






Avatar of MJ

ASKER

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!
Avatar of MJ

ASKER

I fixed it! It was because I had the funtion returning false. I just removed it!
Thanks for the points.