www.webdeveloper.com
Results 1 to 5 of 5

Thread: passing values from iframe

  1. #1
    Join Date
    Jan 2009
    Posts
    27

    passing values from iframe

    hello everyone,

    I am new with iframes. Currently I am creating an iframe within an existing form. The main form has couple of checboxes, and also the iframe has couple of checkboxes. I want to pass the values of iframe checkboxes to another page when a submit button is clicked. The submit button is present in the main page. Is there a way to do this. I was trying to use a hidden text box in the main page which will get populated with the iframe checkbox value, but this does not seem to be working.

    Can anyone suggest anyother way of doing?

    Thanks

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    are the two pages on the same server?

  3. #3
    Join Date
    Jan 2009
    Posts
    27
    yes they are on the same server.my code is something like this

    framesinline.cfm

    <html>
    <script language="javascript" type="text/javascript">

    function checKer(inputID) // where inputID = checkbox
    {
    var x = document.ScannedSearch.elements[inputID];
    var y = window.iframecat.document.SelectCategories.IFrame1;
    if(y.checked == true)
    {
    alert('Is checked and has a value of y = ' + y.value);
    }
    else
    {
    alert('Is not checked');
    }
    }
    </script>
    <body>
    <form name="ScannedSearch" method="post" action="filler1.cfm">
    <input type="text" name="iframecategories" value="">
    IFrame3: <input type="checkbox" id="testcheck" value="IFrame3" onClick="checKer('testcheck')";/>
    IFrame4: <input type="checkbox" name="try2" value="IFrame4" />


    <iframe id="iframecat" src="filler.cfm">


    </iframe>
    <input type="submit" name="submit" value="Go"/>

    <br>
    <br>
    <br>
    </form>
    </body>
    </html>

    filler.cfm

    <html>


    <form action="filler1.cfm" name="SelectCategories" method="post">
    IFrame1: <input type="checkbox" name="IFrame1" id="IFrame1" onclick="checKer('IFrame1');"/>
    IFrame2: <input type="checkbox" name="IFrame2" id="IFrame2" onclick="checKer('IFrame2');"/>

    </form>
    </html>

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    var ifOb =document.getElementById("iframecat");
    var y = ifOb.document.forms["SelectCategories"].IFrame1;

  5. #5
    Join Date
    Jan 2009
    Posts
    27
    I am sorry but my first iframes.cfm page is like follows. I have around 5 checkboxes, so I am the id of that checkbox as an argument, and it shows object expected error.

    <html>
    <script language="javascript" type="text/javascript">

    function checKer(inputID) // where inputID = checkbox
    {
    var x = document.ScannedSearch.elements[inputID];
    var ifOb =document.getElementById("iframecat");
    var y = ifOb.document.forms["SelectCategories"].elements[inputID];
    if(y.checked == true)
    {
    alert('Is checked and has a value of y = ' + y.value);
    }
    else
    {
    alert('Is not checked');
    }
    }
    </script>
    <body>
    <form name="ScannedSearch" method="post" action="filler1.cfm">
    <input type="text" name="iframecategories" value="">
    IFrame3: <input type="checkbox" id="testcheck" value="IFrame3" onClick="checKer('testcheck')";/>
    IFrame4: <input type="checkbox" name="try2" value="IFrame4" />


    <iframe id="iframecat" src="filler.cfm">


    </iframe>
    <input type="submit" name="submit" value="Go"/>

    <br>
    <br>
    <br>
    </form>
    </body>
    </html>

    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles