HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
open a new window in form with an action
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form
View previous topic :: View next topic  
Author Message
pearsont74



Joined: 13 Mar 2008
Posts: 2

PostPosted: Thu Mar 13, 2008 12:41 pm     open a new window in form with an action Reply with quote

ok...i searched and found javascrtiping to open a new window onclick event but my form does a get with an action to an aspx page and if i add the open.window infront of this action it doesnt work and if i add the open.window in a onclick event is opens 2 windows

Code:

 <form name="Form1" method="get" action="../lookup2/phydatagrid.aspx?tablename=physicians" onsubmit="return validateZIP(this.zipcode.value, this.radius.value, this.name)" target="_blank">


can this be done?
ogsolution



Joined: 26 Dec 2007
Posts: 144

PostPosted: Thu Mar 13, 2008 10:37 pm     Reply with quote

Try it this way...

Code:
<html>
<head>
   <script type="text/javascript">
      function validateZIP(){
         //Do the validation
         
         //If everything validates, open window
         window.open("../lookup2/phydatagrid.aspx?tablename=physicians");
         return false; //very important that you return false!!!
      }
   </script>
</head>
<body>
<form name="Form1" action="" onsubmit="return validateZIP(this.zipcode.value, this.radius.value, this.name);">
   <input type="submit" value="Submit">
</form>
</body>
</html>


Since you are using a GET, you don't necessarily need to do a real submit. Instead, you can just do window open in your javasript function.

Remember, return false is VERY IMPORTANT in this and be sure to have return in the onsubmit as well. Or else, it'll do a submit when the validate function finishes running.
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial