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

  • Home
  • SEARCH
  • 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 8584307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:44:36+00:00 2026-06-11T21:44:36+00:00

I need to make a button’s target different from the main submit value. I

  • 0

I need to make a button’s target different from the main submit value. I am using jquery with code below:

HTML:

<form action="somepage" id="cartform" target="_parent" method="post">

(So default action is parent)

JQUERY:

$("#refresh").click(function(){
    $("#cartform").attr('target', '_self');
});

(“Refresh” is the form’s extra button to keep the form in a popup box)

  • 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-06-11T21:44:38+00:00Added an answer on June 11, 2026 at 9:44 pm

    Try to add a listener on submit instead of click:

    $('cartform').on('submit',function(){
       $(this).attr('target', '_self');
    });
    

    Obv it’s the case only if you always want the target to change as the form is submitted. Otherwise, try with your code and preventDefault.

    $("#refresh").click(function(ev){
        ev.preventDefault();
        $("#cartform").attr('target', '_self').submit();
    });
    

    I think the form is being submitted before the target change applies.


    Edit

    Actually, OP is trying to submit a form inside an iframe. This should work:

    $("#refresh").click(function(ev){
        ev.preventDefault();
        $("#cartform").attr('target', 'name_of_the_iframe').submit();
    });
    

    Will submit to:

    <iframe name="name_of_the_iframe" ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a Image button from PNG icons, I need to make a
I need to make a button to dismiss the child view controller from a
I need to make a button that will display different things depending on the
I need to make a toggle button using two image instead of ON/OFF state.
How can I make a button in the html you need to send files
My text box accept alphanumeric and on submit button click I need to make
I need to make disable or inactive the home button of my android phone
I need to make a button that increments and decrements a variable. When you
I need to make a simple refresh button for a gui java program I
On iPad/iPhone, Do you still need to make an invisible button on background to

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.