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 7670181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:45:47+00:00 2026-05-31T15:45:47+00:00

I recently asked a similar question Close Colorbox iframe after form submit and then

  • 0

I recently asked a similar question Close Colorbox iframe after form submit and then redirect parent page but have since changed direction a little so I thought best to create a new post.

I have an add to cart form inside of an iframe(both my parent and iframe reside on the same server/directory). On submit I would like to pass the form to a script on the parent page. the script will close the iframe(colorbox) window and submit the form, but there is one exception; I have two versions of my site, one for standard browsers which uses an iframe to display the the product, and a mobile site which directly opens the product page and works fine as-is. Both use the same database where the info is stored, which means the forms are always the same, So I need a conditional, something along the lines of if this page is in an iframe (pass form to script on parent for submission) else (submit form as-is). I have found this snippet here on stackoverflow that I believe should work for the conditional:

if (top === self) { not in a frame } else { in a frame }

I have three different forms, each is on a separate product page:

The most basic:

<form name="add_cart" action="index.php?action=add" method="post" 
enctype="multipart/form-data">

<input type="hidden" name="quantity" value="1" /> 
<input type="hidden" name="products_id" value="1" /> 
<input type="hidden" name="id[1]" value="1" id="att-1-1" />
<input type="hidden" name="id[2]" value="2" id="att-2-2" /> 


<input class="cssButton button" type="submit" value="Add Product"/> 
</form>

Then one with multiple checkbox selections:

<form enctype="multipart/form-data" method="post" action="index.php?action=add" 
name="cart_quantity">

<input type="hidden" value="1" name="quantity">
<input type="hidden" value="3" name="products_id">

<input id="option-8-1" type="checkbox" value="1" name="id[8][1]">
<input id="option-8-2" type="checkbox" value="2" name="id[8][2]">
<input id="option-8-3" type="checkbox" value="3" name="id[8][3]">
<input id="option-8-4" type="checkbox" value="4" name="id[8][4]">

<input class="cssButton button" type="submit" value="Add Selected Items" >
</form>

And a third with a drop down selection for a single option:

<form enctype="multipart/form-data" method="post" action="index.php?action=add" name="cart_quantity">


<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="products_id" value="3" />  
<input type="hidden" name="id[6]" value="9" id="att-6-9" /> 

<select name="id-7" id="options">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
</select>

I’m looking for any help or guidance into getting this to work. While I have a better grip on javascript, Jquery would be fine, Anything is appreciated.

  • 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-31T15:45:49+00:00Added an answer on May 31, 2026 at 3:45 pm

    You don’t need a conditional, just use javascript unobtrusively, ie if javascript is enabled, javascript stops (hijacks) the form submission, sends the form data to parent and closes the iframe – if javascript is not enabled, the form submits normally: e.g. with jQuery

    <form id="my-form">
    </form>
    
    <script>
        function formSubmissionHandler(){
            // handle form submission
        }
    
        $(document).ready(function(){
            $('#my-form').submit(function(){
                formSubmissionHandler();
                return false;
            });
        });
    </script>
    

    http://en.wikipedia.org/wiki/Unobtrusive_JavaScript

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a similar question recently, but didn't get a clear answer because I
I recently asked this question , but after some of the responses and some
I realize that there was a similar question asked here , but this is
This question is very similar to one I recently asked: Python threading- returning control
I recently asked this question in the pyglet-users group, but got response, so I'm
I recently asked a question on dynamically forming YouTube iframe src which was answered
I recently asked a question about committing a new file but now I am
I recently asked a question about IIf vs. If and found out that there
I recently asked a question about what I called method calls. The answer referred
I recently asked a question about Oracle Encryption. Along the way to finding a

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.