Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Thanked 1 Time in 1 Post

    Passing Iframe URL to PHP (putting Javascript var in form)

    I don't know if this is the best way to do it but I needed script to get the SRC of the iframe on my page and send it to server via Ajax...I found the below script and modified it...

    I know how to send form elements but how do I send the myFrameUrl variable? I was thinking of putting it in a hidden input but can't figure out how?...
    <title>AJAX Example</title>
    <script src="prototype-1.3.1.js" type="text/javascript"></script>
    <script type="text/javascript">
    function send(){
    var params = Form.serialize($('myForm'));
    new Ajax.Updater('updateDiv', 'backend.php', {asynchronous:true, parameters:params});
    var myFrameUrl = document.getElementById('myFrame').src;
    <div id="updateDiv"></div>
    <iframe id="myFrame" src="http://google.com/" height="200px" width="200px"></iframe>
    <form id="myForm">
    <input name="myFrameUrl" type="hidden"><br>
    <input name="sendbutton" type="button" value="Send" onClick="send();">

  2. #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Thanked 163 Times in 160 Posts
    var myFrameUrl = document.getElementById('myFrame').src;
    var params = Form.serialize($('myForm')) + '&url=' + escape(myFrameUrl);
    new Ajax.Updater('updateDiv', 'backend.php', {asynchronous:true, parameters:params});
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts