Submitting a form via JavaScript to a new window with out form tags.

I need t be able to submit a form with a single text box to another site for purposed of searching without the benefit of any form tags.

Our website runs on DotNetNuke and that has total control over the forms tags on each page. Otherwise, I'd just set the target attribute and be done with it.  I've got the form running within the same browser window but really want it to go to another window - not sure if a new browser window a'la 'target="_blank" is a possibility or if window.open is my only option.  I've seen lots of examples but everything relies on the form tag and that's something I don't have.  My feeble efforts either kill the form altogether or launch a window and kill the existing page. Any help would be greatly appreciated.

The code I'm using to submit the form is:

onclick="this.form.action='http://www.myexternallink.com/sales/find';this.form.submit();"

Open in new window


Many thanks in advance.
saabStoryAsked:
Who is Participating?
 
Kiran SonawaneProject LeadCommented:
Look at this below code
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kiran Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

<script>
 $(document).ready(function(){
   $("#submit").click(function(){
     data = $("input, select, textarea").serialize();
     window.location = "http://www.google.com?" + data;
     
   });
   
 });

</script>
</head>

<body>
<input type="text" name="FistName" id="FistName" />
<input type="text" name="FistName" id="FistName" />
<input class="submit" id="submit" type="submit" value="Submit">

</body>

</html>

Open in new window

0
 
hankknightCommented:
Would it be acceptable to send the form data using the GET method, or must it be send using the POST method?  
0
 
leakim971PluritechnicianCommented:
var param1 = encodeURIComponent( document.getElementById("field1_ID") );
var param2 = encodeURIComponent( document.getElementById("field2_ID") );
var paramN = encodeURIComponent( document.getElementById("fieldN_ID") );

location.href = "http://www.myexternallink.com/sales/find?param1=" + param1 + "&param2=" + param2 + "&paramN=" + paramN;

 

Open in new window


use $_GET (php), doGet(servlet), on the server side instead POST
0
 
saabStoryAuthor Commented:
Just what I needed.  I couldn't use anything with GET as I'm sending the values from my for to the website of another company.  No big deal - just looking up event locations based on a zip code.

Many thanks this will work just great!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.