?
Solved

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

Posted on 2011-10-17
4
Medium Priority
?
122 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:saabStory
4 Comments
 
LVL 16

Expert Comment

by:hankknight
ID: 36983271
Would it be acceptable to send the form data using the GET method, or must it be send using the POST method?  
0
 
LVL 83

Expert Comment

by:leakim971
ID: 36983272
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
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 2000 total points
ID: 36983889
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
 

Author Closing Comment

by:saabStory
ID: 37002971
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

850 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