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

Posted on 2011-10-17
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 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:


Open in new window

Many thanks in advance.
Question by:saabStory
    LVL 16

    Expert Comment

    Would it be acceptable to send the form data using the GET method, or must it be send using the POST method?  
    LVL 81

    Expert Comment

    var param1 = encodeURIComponent( document.getElementById("field1_ID") );
    var param2 = encodeURIComponent( document.getElementById("field2_ID") );
    var paramN = encodeURIComponent( document.getElementById("fieldN_ID") );
    location.href = "" + param1 + "&param2=" + param2 + "&paramN=" + paramN;

    Open in new window

    use $_GET (php), doGet(servlet), on the server side instead POST
    LVL 17

    Accepted Solution

    Look at this below code
    <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="" type="text/javascript"></script>
         data = $("input, select, textarea").serialize();
         window.location = "" + data;
    <input type="text" name="FistName" id="FistName" />
    <input type="text" name="FistName" id="FistName" />
    <input class="submit" id="submit" type="submit" value="Submit">

    Open in new window


    Author Closing Comment

    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!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
    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…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now