Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Page refresh added into a Php page

Avatar of TradingChief
TradingChief asked on
JavaPHPJSP
7 Comments1 Solution533 ViewsLast Modified:
I got this script from here it was authored by daedsi:
It is exactly what I need and it works. However I am inserting it into a php page and as long as I keep the entire script intact above the start of the php part of the page, it works great. As soon as I jump into the center of my php and insert a stop php and add the menu part and restart php, the menu appears exactly where I want it. The problem is, The menu itself does not remember I selected 1 minute refresh and on enabling goes back to the "dont reload automatically". The url is modified to Value 1 and it refreshes every one minute, however you no longer can select Don't Reload Automatically".
Again, as long as I leave the script intact it works great, but the drop down skews my page header.
I am not a programmer, I "play" :) My first guess is it has something to do with body and head tags so removed them and that didn't work either. Here is daedsi's code

<html><head><title></title>
<script language="javascript">
<!--
function doLoad(){
  url = window.location.href;
  if(url.search(/\?/g) != -1){
    val = url.split("?");
    set = val[1].split("=");
    time = document.forms[0].elements[0].options[set[1]].value;
    timeOut = setInterval("window.location.reload()", time * 60000);
    document.forms[0].elements[0].selectedIndex=set[1];
  }
}
function fnSetTimeout(item){
  if(item.selectedIndex==0){
    window.location.href="reLoadTest.html";
  }else{
    window.location.href="reLoadTest.html?Value=" + item.selectedIndex;
  }
}
//-->
</script>

</head><body onLoad="doLoad();">
<form>
  <select name="Refresh" size="1" onChange="fnSetTimeout(this);">
    <option value="0" selected>Don't reload automatically</option>
    <option value="1">Reload page every minute</option>
    <option value="2">Reload page every 2 minutes</option>
    <option value="5">Reload page every 5 minutes</option>
    <option value="10">Reload page every 10 minutes</option>
    <option value="15">Reload page every 15 minutes</option>
  </select>
</form>
</body></html>

---------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------

This is what I wanted to do on my php page
----------------------------------------------------------------------------------------------------------------------------

<html><head><title></title>
<script language="javascript">
<!--
function doLoad(){
  url = window.location.href;
  if(url.search(/\?/g) != -1){
    val = url.split("?");
    set = val[1].split("=");
    time = document.forms[0].elements[0].options[set[1]].value;
    timeOut = setInterval("window.location.reload()", time * 60000);
    document.forms[0].elements[0].selectedIndex=set[1];
  }
}
function fnSetTimeout(item){
  if(item.selectedIndex==0){
    window.location.href="http://mysite.com/en/stboard.php";
  }else{
    window.location.href="http://mysite.com/en/stboard.php?Value=" + item.selectedIndex;
  }
}
//-->
</script>
</html>
---------------------------------------------------------------------
PHP FOR PAGE BEGINS
----------------------------------------------------------------
<?php

My php coding for the page
?>
--------------------------------------------------------
INSERT MENU
--------------------------------------------------------------
<body onLoad="doLoad();">
<form>
  <select name="Refresh" size="1" onChange="fnSetTimeout(this);">
    <option value="0" selected>Don't reload automatically</option>
    <option value="1">Reload page every minute</option>
    <option value="2">Reload page every 2 minutes</option>
    <option value="5">Reload page every 5 minutes</option>
    <option value="10">Reload page every 10 minutes</option>
    <option value="15">Reload page every 15 minutes</option>
  </select>
</form>
</body></html>
------------------------------------------------------------
End menu and restart rest of php coding
-----------------------------------------------------
<?

The rest of my page
?>