0

I have this variable on my form

<script>
     var type = 2;
</script>

and on the same page I am calling this iFrame

<iframe src='http://www.genpowerusa.com/crm/formal_quote_new2.php' frameborder='0'></iframe>

What I am unsure is, how could I send the variable to the php form and use the variable on the quote form, the variable is static, I have two pages that call the same iFrame.

Is such thing possible?

1
  • PHP will have finished execution before the browser even sees the <script> tags. You might want to look into using AJAX. Commented Feb 23, 2014 at 17:51

2 Answers 2

2

Assign an id to your iframe:

<iframe id='foo' src='http://www.genpowerusa.com/crm/formal_quote_new2.php' frameborder='0'></iframe>

Add a js line:

document.getElementByid("foo").src='http://www.genpowerusa.com/crm/formal_quote_new2.php?type='+type;

What this does is,pass your variable as a PHP url parameter.You can access it by using the following code in php:

$type=$_GET['type'];
Sign up to request clarification or add additional context in comments.

Comments

0

Sending information via javascript to a frame that is not in the domain of the scope is not possible, because of cross site scripting. That would not be secure (e.g. imagine inserting an iframe with Facebook and grabbing some data from the frame...).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.