anifled
12-11-2003, 08:01 PM
I have a modal window. On closing the window (using the X) I want to be able to check if data has been input. If it hasn't I want to stop the closing and have the user input the needed data. If I could disable the X that would solve my problem. According to my searches that is not possible. Anyway here is my code. Can anyone help?
<html>
<head>
<title> AE Reason for Denial </title>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<script language="javascript">
var callerWindowObj = dialogArguments;
function passData() {
/*
*@ Grab the data from current popup.
*/
var vInput = null;
var V55 = eval("document.forms[0].P_RAD1");
if(V55[0].checked) {
vInput = V55[0].value;
}
else if (V55[1].checked) {
vInput = V55[1].value;
}
else if(V55[2].checked) {
if(document.forms[0].P_TXT1.value=="") {
alert('Please enter Other reasons for denial');
return;
}
else {
vInput = document.forms[0].P_TXT1.value;//V5[2].value;
}
}
else {
alert("Please select one option");
return;
}
/*
*@@ Push the data to opener.
*/
// var callerWindowObj = dialogArguments;
// var vVal = window.opener.document.forms[0].flag.value;
var vVal = callerWindowObj.document.forms[0].flag.value;
// window.opener.document.forms[0].bFlag.value = "Y";
callerWindowObj.document.forms[0].bFlag.value = "Y";
// var doc = window.opener.document;
var doc = callerWindowObj.document;
var oTbl = doc.getElementById("tbl22");
oTbl.setAttribute("border","0");
oTbl.setAttribute("bgColor","#DEE8FF");
var tbl = doc.getElementById("tbl88");
v1 = doc.createElement("TR");
v2 = doc.createElement("TD");
v2.innerHTML = vVal;
v3 = doc.createElement("TD");
v3.innerHTML = vInput;
v1.appendChild(v2);
v1.appendChild(v3);
tbl.appendChild(v1);
/*
*@@@ Close the current window.
*/
window.close();
}//end function
function selectOption(fFiled) {
if(typeof(fFiled) == "string") {
var sF = fFiled.substring(0,fFiled.indexOf(','));
var sVal = fFiled.substring(fFiled.indexOf(','+1,fFiled.length);
//alert("F "+sF+" V "+sVal);
var Obj = eval("document.forms[0]."+sF);
if(typeof(Obj) == "object") {
for(var k=1;k<Obj.length;k++) {
//alert("VAL "+Obj[k].value);
if (Obj[k].value==sVal) {
// alert("inside");
Obj[k].checked = true;
}//if
}//for
}//if
}//if
}//selectOption
function postClose() {
// window.opener.document.forms[0].bFlag.value = "Y";
callerWindowObj.document.forms[0].bFlag.value = "Y";
}
</script>
</head>
<body onUnLoad="javascript:postClose();">
<form name="pvcform">
<table width="250" cellspacing="0" cellpadding="0">
<tr>
<td WIDTH="250" class="subsectionHdr" align="left" >Please select/enter reason for denial</td>
</tr>
<tr>
<td WIDTH="250" class="subsectionHdr">
<input type="radio" name="P_RAD1" value="Exceeds working hours"/>Exceeds working hours<BR/>
<input type="radio" name="P_RAD1" value="Exceeds admin time allowed"/>Exceeds admin time allowed<BR/>
<input type="radio" name="P_RAD1" checked value="Other"/>Other<BR/>
<TEXTAREA ROWS="5" NAME="P_TXT1" COLS="25" onKeyPress="javascript:selectOption('P_RAD1,Other');" ></TEXTAREA> <BR/><BR/>
<input type="button" value="OK" onClick="javascript:passData();"/>
<input type="reset" value="Clear"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title> AE Reason for Denial </title>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<script language="javascript">
var callerWindowObj = dialogArguments;
function passData() {
/*
*@ Grab the data from current popup.
*/
var vInput = null;
var V55 = eval("document.forms[0].P_RAD1");
if(V55[0].checked) {
vInput = V55[0].value;
}
else if (V55[1].checked) {
vInput = V55[1].value;
}
else if(V55[2].checked) {
if(document.forms[0].P_TXT1.value=="") {
alert('Please enter Other reasons for denial');
return;
}
else {
vInput = document.forms[0].P_TXT1.value;//V5[2].value;
}
}
else {
alert("Please select one option");
return;
}
/*
*@@ Push the data to opener.
*/
// var callerWindowObj = dialogArguments;
// var vVal = window.opener.document.forms[0].flag.value;
var vVal = callerWindowObj.document.forms[0].flag.value;
// window.opener.document.forms[0].bFlag.value = "Y";
callerWindowObj.document.forms[0].bFlag.value = "Y";
// var doc = window.opener.document;
var doc = callerWindowObj.document;
var oTbl = doc.getElementById("tbl22");
oTbl.setAttribute("border","0");
oTbl.setAttribute("bgColor","#DEE8FF");
var tbl = doc.getElementById("tbl88");
v1 = doc.createElement("TR");
v2 = doc.createElement("TD");
v2.innerHTML = vVal;
v3 = doc.createElement("TD");
v3.innerHTML = vInput;
v1.appendChild(v2);
v1.appendChild(v3);
tbl.appendChild(v1);
/*
*@@@ Close the current window.
*/
window.close();
}//end function
function selectOption(fFiled) {
if(typeof(fFiled) == "string") {
var sF = fFiled.substring(0,fFiled.indexOf(','));
var sVal = fFiled.substring(fFiled.indexOf(','+1,fFiled.length);
//alert("F "+sF+" V "+sVal);
var Obj = eval("document.forms[0]."+sF);
if(typeof(Obj) == "object") {
for(var k=1;k<Obj.length;k++) {
//alert("VAL "+Obj[k].value);
if (Obj[k].value==sVal) {
// alert("inside");
Obj[k].checked = true;
}//if
}//for
}//if
}//if
}//selectOption
function postClose() {
// window.opener.document.forms[0].bFlag.value = "Y";
callerWindowObj.document.forms[0].bFlag.value = "Y";
}
</script>
</head>
<body onUnLoad="javascript:postClose();">
<form name="pvcform">
<table width="250" cellspacing="0" cellpadding="0">
<tr>
<td WIDTH="250" class="subsectionHdr" align="left" >Please select/enter reason for denial</td>
</tr>
<tr>
<td WIDTH="250" class="subsectionHdr">
<input type="radio" name="P_RAD1" value="Exceeds working hours"/>Exceeds working hours<BR/>
<input type="radio" name="P_RAD1" value="Exceeds admin time allowed"/>Exceeds admin time allowed<BR/>
<input type="radio" name="P_RAD1" checked value="Other"/>Other<BR/>
<TEXTAREA ROWS="5" NAME="P_TXT1" COLS="25" onKeyPress="javascript:selectOption('P_RAD1,Other');" ></TEXTAREA> <BR/><BR/>
<input type="button" value="OK" onClick="javascript:passData();"/>
<input type="reset" value="Clear"/>
</td>
</tr>
</table>
</form>
</body>
</html>