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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Refresh Value from popup page to main page

    I created a quick slide show of what I need.

    What I'm looking to do is have a page that has a link to add a new value into the database. When you click the link, a small popup will be shown with a textfield asking you for the value. After typing the value and pressing the save button. The popup box will close and the main page will have the value shown without refreshing the page.

    How can I achive this? I know you would have to use ajax maybe? Or some type of onload method, though I don't know.

    See attachment for clarification. Thanks!
    Attached Thumbnails Attached Thumbnails Refresh Value from popup page to main page-request.gif  

  • #2
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I should note that I know how to do this on one page.

    Main.html
    Code:
    <html>
    <head>
    
    <script language="Javascript">
    function xmlhttpPost(strURL) {
            var xmlHttpReq = false;
            var self = this;
    
            // Mozilla/Safari
            if (window.XMLHttpRequest) {
                    self.xmlHttpReq = new XMLHttpRequest();
            }
    
            // IE
            else if (window.ActiveXObject) {
                    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
    
            self.xmlHttpReq.open('POST', strURL, true);
            self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            self.xmlHttpReq.onreadystatechange = function() {
                    if (self.xmlHttpReq.readyState == 4) {
                            updatepage(self.xmlHttpReq.responseText);
                    }
            }
    
            entrytitle=document.getElementById("entrytitle").value;
            entrytext=document.getElementById("entrytext").value;
    
            qstr = 'entrytitle='+entrytitle+'&entrytext='+entrytext;
            self.xmlHttpReq.send(qstr);
    }
    
    function updatepage(str){
      document.getElementById("mydiv").innerHTML=str;
    }
    </script>
    </head>
    <body>
    <form>
            Title: <input id="entrytitle" type="text"><br>
            Text: <input id="entrytext" type="text"><br>
            <input type="button" value="Submit" onclick="xmlhttpPost('process.php');">
    </form>
    
    <div id="mydiv"></div>
    
    </body>
    </html>
    process.php
    PHP Code:
    <?php

    echo $HTTP_POST_VARS['entrytitle'];
    echo 
    $HTTP_POST_VARS['entrytext'];

    ?>
    I just don't know how to display this on the main page from the popup menu.


  •  

    Posting Permissions

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