View Single Post
  #3 (permalink)  
Old June 10th, 2008, 04:15 PM
oldBroh oldBroh is offline
Registered User
Join Date: Jun 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

Hello vinod

Thanks for the fast reply. Sorry I wasn't close by. I am kinda slow at this, so I will have to play with the code you sent, but I will for sure. In the meantime heres a stripped down version of my code. Its pretty much self explanatory, but what I want, is for the value of innerHTML in A to be available for use after submitting only once. The refresh of values seems to be tied to submit buttons and alert calls. Btw I am only interested in making it work in IE for the time being.

This all works. (just not like I want it to:()



<script src="getdata.js"></script>
<script language = "JavaScript" type = "text/javascript">
    var data = ""
    var dataA = ""

    function prepdata(){
        data = document.getElementById("data").value

        document.getElementById("B") tElementById("A").innerHTML
        dataA = document.getElementById("A").innerHTML
        alert("This is what shows in A before calling alert : "+dataA)

        document.getElementById("B") tElementById("A").innerHTML
        dataA = document.getElementById("A").innerHTML
        alert("This is what shows after calling alert : "+dataA)
    function copydata(){
        document.getElementById("B") tElementById("A").innerHTML


Data to send: <input type="text" size="40" id="data" value="Send this to retrieve new data"/>
<input type="button" name="send" onclick="prepdata()" value="Submit"/>
Submiting twice causes data to update
A. Data returns here, and then is copied to B:<p><div id="A"> A data</div></p><br></br>
B. Data read from A :<p><div id="B">blank</div></p><br></br>
Manual copying of data from A to B causes correct updated reading of innerHTML:<br></br>
<input type="button" name="copy" onclick="copydata()" value="Submit"/>


var xmlHttp

function getdata(str){
    if (xmlHttp==null) {
        alert ("Your browser does not support AJAX!");
    var url="getdata.php";

function stateChanged(){
    if (xmlHttp.readyState==4){
        document.getElementById("A").innerHTML=xmlHttp.res ponseText;

function GetXmlHttpObject(){
    try {
        xmlHttp=new XMLHttpRequest();
    catch (e){
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    return xmlHttp;


$response="Data from PHP";
echo $response;

Thanks again,