Jump to content

Open popup window when page is loaded if a field is populated


Litestream

Recommended Posts

We have an internal database of instructions generated by php.

 

However, many people don't bother to read the critical information section and so errors are made on a daily basis.

 

Would it be possible to open a popup window on loading the instruction page but only when the critical information section of the page contains text?

 

The popup window could either contain the contents of the critical information section or just a visual warning that such information exists on the main page.

 

I have a pretty good knowledge of VBA but sadly my knowledge of php and javascript is very limited.

 

Any help would be greatly appreciated.

Hi, I know this is phpfreaks but javascript would probably be your best bet with this sort of problem and using alert boxes to warn/inform the user.

 

Add this script in the head section of your page.

 

<script language="javascript" type="text/javascript">

  function warning()

  {

    if(criticalInformationCheck())

    {

    alert("Warning! Warning! Warning!, you might want to change warning to something useful");

    }

 

    function criticalInformationCheck()

    {

      var answer = true;

      //how this will work will depend on the DOM of the page you are generating.

      //eg if div exist then anwer is false

      // or if div is empty then answer is false

      return answer;

    }

  }

</script>

 

and add this to the body tag

<body onload="warning()">

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.