By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Submitting a form results in a blank page

P: 1
i m submitting (posting) a form to some external site url . By clicking on submit it opens up new window (target='_blank' set) and my form is submitted there. but if i tries to submit a form using java script by using document.form_name.submit; then new window is opened but i m not getting results.

example:

Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="refresh" content="10"  /> 
  2. <script language="javascript">
  3.     function submit_form()
  4.     {
  5.         document.form1.submit();    
  6.     }
  7. </script>
  8. <?
  9. $no=rand(12,500000);
  10. //echo $no;
  11. ?>
  12.     <form name="form1" method="post" action="http://www.example.com/175942.php" target="_blank">
  13.  
  14.         <input name="txtName" type="text" id="txtName" value="CPPPPPPPPP<?=$no?>   hello">
  15.         <input name="txtName1" type="text" id="txtName1" maxlength="100" value="CCCCCCCCCCPPPPPPPPPP<?=$no?> (NEHA)">
  16.         <input name="txtName2" type="text" id="txtName2" maxlength="100" value="DIVYAAAAAAAAAA (CP)<?=$no?>">
  17.         <input name="txtName3" type="text" id="txtName3" maxlength="100" value="HIIIIIIIIIIII CCCCCCCCCCPPPPPPPPPP<?=$no?>">
  18.         <input name="btnSubmit" type="submit" id="btnSubmit"  onclick="submit_form()" value="Click to find out!"></td>
  19.  
  20. <script language="javascript">
  21. document.form1.submit();
  22. </script>
  23.  
  24.  
  25.     </form>
Sep 20 '07 #1
Share this Question
Share on Google+
2 Replies


dmjpro
100+
P: 2,476
i m submitting (posting) a form to some external site url . By clicking on submit it opens up new window (target='_blank' set) and my form is submitted there. but if i tries to submit a form using java script by using document.form_name.submit; then new window is opened but i m not getting results.

example:

Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="refresh" content="10"  /> 
  2. <script language="javascript">
  3.     function submit_form()
  4.     {
  5.         document.form1.submit();    
  6.     }
  7. </script>
  8. <?
  9. $no=rand(12,500000);
  10. //echo $no;
  11. ?>
  12.     <form name="form1" method="post" action="http://www.example.com/175942.php" target="_blank">
  13.  
  14.         <input name="txtName" type="text" id="txtName" value="CPPPPPPPPP<?=$no?>   hello">
  15.         <input name="txtName1" type="text" id="txtName1" maxlength="100" value="CCCCCCCCCCPPPPPPPPPP<?=$no?> (NEHA)">
  16.         <input name="txtName2" type="text" id="txtName2" maxlength="100" value="DIVYAAAAAAAAAA (CP)<?=$no?>">
  17.         <input name="txtName3" type="text" id="txtName3" maxlength="100" value="HIIIIIIIIIIII CCCCCCCCCCPPPPPPPPPP<?=$no?>">
  18.         <input name="btnSubmit" type="submit" id="btnSubmit"  onclick="submit_form()" value="Click to find out!"></td>
  19.  
  20. <script language="javascript">
  21. document.form1.submit();
  22. </script>
  23.  
  24.  
  25.     </form

Welcome to TSDN.
Use Code Tags while you do Post.
I think for secured reasons it is not happening.
Do you know the JavaScript does not support Cross-Site Scripting?
It does not.

Kind regards,
Dmjpro.
Sep 20 '07 #2

pbmods
Expert 5K+
P: 5,821
Heya, Vikasbatra. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=javascript]
JavaScript code goes here.
[/CODE]

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

If you're getting a blank page, your script is probably generating an error. Check out this article to find out what is going on.
Sep 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.