Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:46:19+00:00 2026-05-24T19:46:19+00:00

I have a regular POST form. I have 2 submit buttons, one is called

  • 0

I have a regular POST form. I have 2 submit buttons, one is called ‘Submit’ and the other is ‘Preview’.

What I want to be done is, when the submit button is clicked, I want the form to be submitted regularly in the same window. But when preview is clicked, I want the form’s action URL to be changed, and for it to be opened in a new window. E.g:

$("#myForm").attr('action', 'http://new-url.com')
   .attr('target', '_BLANK');
$("#myForm").submit();

And right after the new popup window is opened, I want the old action/target attributes to be restored, so if the submit button is then clicked, it would be submitted to the regular url.

How can this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:46:20+00:00Added an answer on May 24, 2026 at 7:46 pm
    <form onsubmit="this.action = 'http://old-url.com'; this.target = '_self';">
    <input type="submit" value="Submit"> <!-- This triggers the onsubmit that resets the action and target -->
    <input type="button" value="Preview" onclick="this.form.action = 'http://new-url.com'; this.form.target = '_blank'; this.form.submit();"> <!-- calling submit() doesn't invoke onsubmit -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have regular form like this. <form action=/domainchecker.php method=post> <input type=text name=domain size=20> <fieldset>
I have this form declaration: <form method=post action=/web_services/buscar_vuelos?method=get> <div id=addSegment_wrapper> <button class=ui-button ui-widget ui-state-default
I have a form with a text-input and a submit button. In the text-input
I have a very simple form with a name field and two submit buttons:
I have a regular form with a url as action to which the form
Server is PHP5 and HTML charset is latin1 (iso-8859-1). With regular form POST requests,
Hi I have managed to get my form to submit without reloading, using this
I have a regular expression to match a persons name. So far I have
I have this regular expression: ^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$ however it is failing when i have an
I have a regular .NET Windows Forms treeview control. The nodes are setup like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.