Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to load pages to iframe using form (client)

    Hi all,

    Can any one tell me how to load up different pages to an inframe using some form. I want to load up page1 or page2 depending on the condition. Sounds simple enough? Here what i have so far: Thanks.

    <script type="text/javascript">
    <!--

    // This is the check script

    function checkit()
    {

    // In textstring I gather the data that are finally written to the textarea.

    var textstring = '';
    var display_selected = '';
    var user_input = '';
    for (i=0;i<document.forms[0].uutType.length;i++) {
    if (document.forms[0].uutType[i].checked) {
    user_input = document.forms[0].uType[i].value;
    display_selected = document.displayOptions.displays.options[document.displayOptions.displays.selectedIndex].value
    if(document.forms[0].uType[i].value=="B")
    {
    switch (display_selected)
    {
    case "NE":
    window.location="page1.html"; //<---
    break
    case "PA":
    window.location="page2.html";//<----
    break

    }//end switch
    }//end if checked
    }//for
    user_input = document.displayOptions.displays.options[document.displayOptions.displays.selectedIndex].value


    }
    // -->
    </script>
    <style type="text/css">
    td[colspan] {
    text-align: center;
    }
    </style>

    </head>
    <body>


    <form name="displayOptions" action="#" onsubmit="checkit(); return false">
    <table class="form">


    <tr>

    <td>
    <input type="radio" name="uType" value="Mxx" />Mxx&nbsp;&nbsp;
    <input type="radio" name="uType" value="Bxx" />Bxx&nbsp;&nbsp;



    <select name="displays">
    <option value='' selected="selected">--- Select ---</option>
    <option value="NE">NES</option>
    <option value="PA">PAS</option>


    </select>&nbsp;&nbsp;
    <input type="submit" value="go" />&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="reset" /></td></tr>

    </table>
    </form>

    <iframe name="IconFera" style="" frameborder="0" scrolling="no" width="627" marginwidth="0" marginheight="0" height="1088" src="default.htm"></iframe>
    </div>

    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    728
    Thanks
    35
    Thanked 132 Times in 123 Posts
    Set the src property of the the iframe.

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what do you mean? Am I not having the src property already (src="default.html") of the iframe?

  • #4
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dont I need a 'target' prop, where target is my iframe name/id? How do I do that with window.location=? Or is there a better way? Thanks

  • #5
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    never mind , I found my answer:
    document.myIframeIDhere.location.href="page1.html"
    document.myIframeIDhere.location.href="page2.html" etc..

  • #6
    New to the CF scene
    Join Date
    Oct 2006
    Location
    India
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You Can Do It In Tis Way Also

    var get_id = document.getElementById("IFrame_Id");
    get_id.src = "page1.html";

    //or//

    get_id.location.href = "page1.html"


  •  

    Posting Permissions

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