R0n1n66 Posted June 14, 2017 Share Posted June 14, 2017 What I am attempting to do is refresh this specific part of the page and have the newly entered data set to the variables in the clock script. The project is a clock that can be manipulated on a web page with 3 other clocks that all can be manipulated as well with out effecting the other clocks. I have included a snippet of code that shows the first clock. Any help would be great. <!doctype HTML> <html style="height: 98%;"> <head> <meta> <title>GC Info Center</title> <link href="clock.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> </head> <body class="background" style="height: 100%;" onload="startTime(); startTimee(); startTimep(); startTimeg(); startTimet(); "> <?php require 'C:\wamp64\www\clock\igtscript.php'; ?> <!-- Page Table --> <table class="main"> <tbody > <!-- Clocks --> <tr > <td class=""> <table class="main"> <tbody> <tr class="content"> <!-- IGT Clock ------------------------------------------------------------------------------------------------> <td style="color: #FFFF00"; class="clockfont" > <script> //Browser Support Code function igtrefresh() { var ajaxRequest; // The variable that makes Ajax possible! try { // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); }catch (e) { // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Function that will receive data // sent from the server and will update // div section in the same page. ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { var ajaxDisplay = document.getElementById('igt'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } }; // Call to php script to querry the data base. ajaxRequest.open("GET" , "igtscript.php" , true); ajaxRequest.send(null); } /* Sets variables from data base for clock*/ var gm = <?php echo $minute; ?>; var gh = <?php echo $hour; ?>; var gmo = <?php echo $month; ?>; var gday = <?php echo $day; ?>; var gyear = <?php echo $year; ?>; var gom =""; /* Clock Mechanics */ function startTimeg() { var gtoday = new Date(); var gs = gtoday.getSeconds(); if (gs == "00") {gm ++ ;} if (gm == "60" && gs == "00") gh ++ ; if (gm == "60" && gs == "00") gm = "0"; if (gh == "24") gh = "0"; if (gm < "10") {gom = "0"; }else {gom = ""; } if (gh < "10") {goh = "0"; }else {goh = ""; } document.getElementById('igt').innerHTML = goh + gh + ":" + gom + gm + ":" + gs + "<br/>" + gmo + " - " + gday + " - " + gyear; var t = setTimeout(startTimeg, 1000); } </script> <script> /* Function to create the pop up window for clock changes */ function popitup(url) { newwindow=window.open(url,'name','height=600,width=450'); if (window.focus) {newwindow.focus();} return false; } </script> <!-- calls the pop up with the update form to change the time --> <div scope="col" ><a href="http://localhost:8080/clock/backendigtclock.php" onclick="return popitup('http://localhost:8080/clock/backendigtclock.php');">IGT</a></div> <!-- Displays the clock. --> <div id="igt"></div> <!-- Refresh the clock to load the new data in the data base for the clock --> <input type='button' onclick='igtrefresh(); ' value='Query MySQL'/> </td> Quote Link to comment https://forums.phpfreaks.com/topic/304125-refreshing-db-variables-inside-scripts-and-loading-the-new-data-to-a-page/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.