SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    germany
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing values in iFrame

    I have a 2 pages
    1. Main page (which contains the iframe) (MainPage)
    2. A page Within IFrame (Sub Page)

    Now i have list of records in sub Page and have a link for each records.
    when a user click that link using that link i need to send a value(values of that record selected) to the mainpage.

    only way of doing is i have to reload the main page.
    I was able to load the main page by using the script
    parent.location.reload();

    but problem i have is i can load the main page from the Subpage but how to pass value from sub page to main page.

    Say i have values
    Code = 95 Type= A Localvalueofthatpaage="ALexander"
    I have these values in Sub Page and have to pass to main page

    I need help very urgently
    thanks in advance
    with regards
    vimal

  2. #2
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From the parent window, you can call the variable (for example a variable named varName) in the iframe with self.frames[0].varName or if you have given the iframe a name value, like frmOne with, self.frmOne.varName

  3. #3
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    germany
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much mr Jvlb,

    i am developing this applicaiton using asp and i am new to asp
    I have a link from the Subpage (page within iframe)
    <td class="<%= ClassName %>"><a href="dsp_search.asp" onClick="parent.reload();"><img src="images/icon_playit.gif" border="0"></a></td>


    Now I have these variables in my Sub page
    Rs.fields("Name")
    Rs.fiedls("COde")
    and local variabel called Say Var1="Alexander"

    Now i need your help in how to access this values from my mainpage using asp
    since i am new to asp , i need some codings from you how to achive this

    thanks for your help
    with regards
    vimal

  4. #4
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm afraid I don't know a great deal about ASP, except that you can use VisualBasic or JavaScript to code its functions. Additionally, on ASP.NET you can use C#. The JavaScript within the page itself should be as I described, but writing the page with ASP is another issue. I can refer you to the ASP forum, at: http://www.sitepoint.com/forums/forumdisplay.php?f=34

  5. #5
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    germany
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mr JVLB,
    Is there a way where , Say i have 3 hidden form elements in my sub page and in onclick event i am initializing those 3 hidden form elements with the values which i need to pass to main page.

    and when the main page reloads , shall i be able to get those form elements ??
    If possible can u put me some code for me?

    Thanks a lot in advance
    with regards
    vimal

  6. #6
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you mean the sub page is a child window of the main page, the data can be passed as long as the main page doesn't reload. Once the main page reloads, it will lose its relationship with the child window. If you are using frames, there would still be complications if you are doing a hard reload (or a forced reload), but there might be a way to use a soft reload, since it doesn't clear forms, that would work.

    If you are using reload simply to update data on the main page, you would probably be better served by investigating innerHTML, a document object property supported by most newer browsers. Unlike document.write(), innerHTML allows scripts to modify data on the currently displayed page.

    See if the following helps. Save the two documents with the names indicated in their titles, then load test_83a.htm and click on the input window to see the action take place.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>test_83a.htm</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    html,body{height:100%;}
    </style>
    <script type="text/javascript">
    function showVar(frm_val){
    var chg_div=document.getElementById("divOne");
    chg_div.innerHTML+=frm_val;
    }
    </script>
    </head>
    <body>
    <div id="divOne"></div>
    <iframe name="frmOne" src="test_83b.htm"></iframe>
    </body>
    </html>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>test_83b.htm</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function tranFrm(){
    parent.showVar(document.frmOne.inOne.value);
    }
    </script>
    </head>
    <body>
    <form name="frmOne" action="" onclick="tranFrm();">
    <input name="inOne" value="test value" />
    </form>
    </body>
    </html>

  7. #7
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    germany
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank u very much for your help

    I have found a easier solution and i thought to tell to u also \

    ie

    u create some hidden form element in main page

    when u click from the sub page

    u assign those values to those main page form elements

    and instead of reload the page u submit the main parents form

    and it works really well.

    function GetnameFile(name,whereqry)
    {
    parent.FrmButtons.Name.value =name;
    parent.FrmButtons.Qry.value =whereqry;
    parent.FrmButtons.submit()
    return true;
    }
    anyway thanks a lot for your help

    thanks and regards
    vimal


Bookmarks

Posting Permissions

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