dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: iFrame effect with javascript and textboxes?

  1. #1
    Join Date
    Dec 2008
    Posts
    11

    Question iFrame effect with javascript and textboxes?

    I've been looking for a script that seems relatively simple but I can't find it anywhere! I guess I just don't know what to call it.

    Basically I just want to be able to have 2 text boxes on a page, and when you click on a link in one box, it changes the content in the second box. It sounds like what iframes did way back when, but I just HATE iframes.

    Is there a javascript equivalent that anyone knows about?

  2. #2
    Join Date
    Aug 2009
    Posts
    17
    You can do that using AJAX, that is if the content you want to display reside on your database or you want to load a page on that particular div but if not, you can write the content of your second box using javascript alone.

    i.e. (JAVASCRIPT)
    function changeContent(dvalue) {
    var div1 = document.getElementById('DIV1_ID');
    if(dvalue == 'RADIO_VALUE1') {
    div1.innerHTML = "YOUR CONTENT HERE. YOU CAN INCLUDE html TAGS ";
    } else {
    div1.innerHTML = "FIRST RADIO BUTTON CONTENT WILL BE DISPLAYED HERE";
    }
    return;
    }

    i.e. (JAVASCRIPT AND AJAX)
    function AjaxRequest()
    {
    if (window.XMLHttpRequest)
    {
    // code for IE7 , Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
    }

    function changeContent(dvalue) {
    var div_id = document.getElementById('div_id');
    xmlHttp = AjaxRequest();
    xmlHttp.open("GET", dvalue, true);
    xmlHttp.onreadystatechange = function () {
    if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
    div_id.innerHTML = xmlHttp.responseText;
    }
    }
    xmlHttp.send(null);
    return;
    }
    NOTE: make sure that the value of your radio button is a link for this to work

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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