PDA

View Full Version : calling Window Widget using div option from php script



alvabaker
08-02-2014, 05:07 PM
1) Script Title: DHTML Window Widget

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem: I want to call the Window Widget script (using the div option) from a php script and not use the html href onClick method. Here is why.

I am developing an application that collects data about a patient's disease(s). The user selects the disease(s) applicable to the patient and then can enter the data for each chosen disease. After choosing the disease(s), which are saved to a file [CertCheck.txt], the file is read and for each disease, a popup holds the disease entry code.

This may be viewed at www.grnmd.com/CertCheck/DiseaseData.php, which uses the onClick method. The code is not posted in this form due to character limits, but the code may be seen at www.grnmd.com/CertCheck/DiseaseData.txt



The challenge is that I am checking for the presence of the individual disease-specific data files (i.e., HeartInfo.txt) to give a message to the user that data has been entered (or not) for each disease. The disease-specific data file (i.e., HeartInfo.txt) for each disease is created in the code within the popup for that disease. For example, for cancer (in CancerInfo.php):


******* Code of CancerInfo.php **********

<!DOCTYPE html>

<html>
<head>
<title> Cancer Information </title>

<style type="text/css">
</style>

</head>


<body onLoad="placeIt()">

<div style="margin-left:30px">

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

<p><strong>Cancer information</strong> (choose one):</p>
<blockquote>
<input type="radio" Name="Cancer1" value="Bx">Patient has biopsy-proven primary-site malignancy <br>
<input type="radio" Name="Cancer1" value="NoPrimary">Patient has metastatic disease, primary site unknown <br><br>
</blockquote>

<p><strong>Treatment information</strong></p>
<blockquote>
<p><u>Previous treatment</u> (choose all that apply):</p>
<blockquote>
<input type="Checkbox" Name="Cancer3" value="SurgeryPre">Patient has had surgery.<br>
<input type="Checkbox" Name="Cancer4" value="ChemoPre">Patient has had chemotherapy<br>
<input type="Checkbox" Name="Cancer5" value="RadsPre">Patient has had radiation therapy
</blockquote>

<p><u>Current and projected treatment</u> (choose all that apply):</p>

<blockquote>
<input type="Checkbox" Name="Cancer6" value="4CureNow">Patient is receiving aggressive/curative radiation or chemotherapy<br>
<input type="Checkbox" Name="Cancer7" value="PallTxNow">Patient is receiving palliative radiation or chemotherapy<br>
<input type="Checkbox" Name="Cancer8" value="4CureFuture">Patient has planned future aggressive/curative therapy of any modality
</blockquote>
</blockquote><br>


<p><strong>Primary Site, if known</strong></p>
<blockquote>
Choose the general site for the primary cancer. <br>
<br>
<input type="radio" name="Cancer9" value="CNS"> Central Nervous System<br>
<input type="radio" name="Cancer9" value="head"> Head and Neck<br>
<input type="radio" name="Cancer9" value="lung"> Lung<br>
<input type="radio" name="Cancer9" value="GI"> Gastrointestinal, upper<br>
<input type="radio" name="Cancer9" value="colon"> Colorectal/anal<br>
<input type="radio" name="Cancer9" value="liver"> Hepatic<br>
<input type="radio" name="Cancer9" value="pancreas"> Pancreas<br>
<input type="radio" name="Cancer9" value="blood"> Hematopoetic<br>
<input type="radio" name="Cancer9" value="lymph"> Lymphatic<br>
<input type="radio" name="Cancer9" value="renal"> Kidney<br>
<input type="radio" name="Cancer9" value="bladder"> Bladder<br>
<input type="radio" name="Cancer9" value="GUM"> Genital, male<br>
<input type="radio" name="Cancer9" value="GUF"> Genital, female<br>
<input type="radio" name="Cancer9" value="bone"> Bone<br>
<input type="radio" name="Cancer9" value="skin"> Skin<br>
<input type="radio" name="Cancer9" value="other"> Other<br>
<blockquote>If other, please enter site:<br>

<textarea Name="Cancer10" rows="1" cols="50" maxlength="50" wrap="soft">
</textarea>
</blockquote>

</blockquote>


Additional clinical information (400 characters):<br>
<textarea Name="Cancer11" rows="4" cols="50" maxlength="450" wrap="soft">
</textarea>

<br>

<input type="Submit" value="Record Data">
</form>

<br>

<?php

$myFile = "CancerData.txt";
$fh = fopen($myFile, 'w') or die("can't open file");



if (count($_POST) > 0 && isset($_POST["Cancer1"])) {
echo "1. ".$_POST["Cancer1"]."<br>";
$n0 = $_POST["Cancer1"];
$n1 = $n0."\n";
fwrite($fh, $n1);

}

if (count($_POST) > 0 && isset($_POST["Cancer2"])) {
echo "2. ".$_POST["Cancer2"]."<br>";
$n0 = $_POST["Cancer2"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer3"])) {
echo "3. ".$_POST["Cancer3"]."<br>";
$n0 = $_POST["Cancer3"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}


if (count($_POST) > 0 && isset($_POST["Cancer4"])) {
echo "4. ".$_POST["Cancer4"]."<br>";
$n0 = $_POST["Cancer4"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer5"])) {
echo "5. ".$_POST["Cancer5"]."<br>";
$n0 = $_POST["Cancer5"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer6"])) {
echo "6. ".$_POST["Cancer6"]."<br>";
$n0 = $_POST["Cancer6"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer7"])) {
echo "7. ".$_POST["Cancer7"]."<br>";
$n0 = $_POST["Cancer7"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer8"])) {
echo "8. ".$_POST["Cancer8"]."<br>";
$n0 = $_POST["Cancer8"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer9"])) {
echo "9. ".$_POST["Cancer9"]."<br>";
$n0 = $_POST["Cancer9"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer10"])) {
echo "10. ".$_POST["Cancer10"]."<br>";
$n0 = $_POST["Cancer10"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}

if (count($_POST) > 0 && isset($_POST["Cancer11"])) {
echo "11. ".$_POST["Cancer11"]."<br>";
$n0 = $_POST["Cancer11"];
$n1 = $n0."\n";
fwrite($fh, $n1);
}


fclose($fh);

?>


</div>

</font>
</font>
</div>

</body>
</html>

*********** end of code for CancerInfo.php **********

It appears that all of the php "includes" in the popup divs create the disease-specific files when any of the popups are run. Such that, if the user opens the popup to enter data about cancer, the data file for heart is also created. Thus, when the user exits the cancer popup, the used is told that data for heart is already entered, even though it has not been.

To get around this, I am trying to put the call for the popup in a php function, so that the "include" code in the div associated with Window Widget is not executed until the function is called. In trying to figure this out, I have created a test program that attempts to call the Window Widget script from within php. It works fine (the popup window opens, has a title) EXCEPT that the content of the associated div is not loaded into the popup window. The test code that demonstrates this is at www.grnmd.com/CertCheck/GoTest2.php. The code is as follows:


************ code of GoTest2.php *****************

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TestGo2</title>


<script>
function myFunction()
{
alert("No action taken!");
}
</script>

<link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />

<!-- the following script handles the popup windows-->
<script type="text/javascript" src="windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>

</head>

<body>

<h3> Data Entry </h3>



<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<?php
$fit="No";
echo "<br>"."<br>";
?>

<blockquote>
<input type="radio" Name="HeartGo" value="Yes">select and click "Go" to take action (enter data).<br>
<input type="radio" Name="HeartGo" value="Bail">select and click "Go" to NOT take action.<br>

<input type="Submit" value="Go">
</blockquote>
</form>

<?php

if (count($_POST) > 0 && isset($_POST["HeartGo"])) {
$fit = $_POST["HeartGo"];
}

if ($fit=="Yes") {

echo '<a href="#" ></a>';


echo '<script type="text/javascript">divwin=dhtmlwindow.open(\'divbox2\', \'div\', \'somediv2\', \'Select patient characteristics related to Cancer\', \'width=900px,height=450px,left=40px,top=80px,resize=0,scrolling=1\')</script>';

} elseif ($fit=="Bail") {
writeMsg();
}

?>



<?php
function writeMsg() {
echo '<script type="text/javascript">myFunction()</script>';
}

?>



<div id="somediv2" style="display:none">

<p> In the div</p>

<?php include("CancerInfo.php"); ?>

</div>

</body>
</html>

************* end of code for GoTest2.php ***********

The issue seems to be that when the Window Widget script is called from the php script instead of using the onClick statement, it can't find the div. The help I am asking for is to find out how to call the Window Widget script, using the div option, from the php script. Thanks to anyone in advance for helping me.