zinjamaster
10-11-2007, 05:56 PM
1) Script Title:
DHTML Window Script
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm
3) Describe problem:
I have issues with setting the value property of text boxes and also with focus and onChange events. In Firefox, most things work fine. I can set the focus using
document.getElementById('text1').focus();
However, in IE - the first time the page loads, it will work, but after that - no worky. I imagine it has something to do with the method I am using to render html.
I also can use the onChange event in Firefox with no issues - IE ignores the ENTER key after changing the value in the textbox, the TAB key works, but not the ENTER key.
Here is a brief rundown of how I am rendering the html:
I have references to my main javascript on a PHP script (index.php). Using the window.onload event (in allcarepos.js) , I execute a function to get things started. Here is some of my code (I hope it is enough to help figure this out)
file: index.php
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
echo "<html xmlns='http://www.w3.org/1999/xhtml'>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />";
echo "<head>";
echo "<link rel=\"stylesheet\" href=\"css/selrow.css\" type=\"text/css\">";
echo "<link rel=\"stylesheet\" href=\"windowfiles/dhtmlwindow.css\" type=\"text/css\">";
echo "<link rel=\"stylesheet\" href=\"modalfiles/modal.css\" type=\"text/css\">";
echo "<link rel=\"stylesheet\" href=\"css/acpos.css\" type=\"text/css\">";
echo "<script type='text/javascript' src='xmlhttp.js'></script>";
echo "<script type='text/javascript' src='acpos_functions.js'></script>";
echo "<script type='text/javascript' src='windowfiles/dhtmlwindow.js'></script>";
echo "<script type='text/javascript' src='modalfiles/modal.js'></script>";
if ($_GET['req'] <> 'noregister')
{
echo "<script type='text/javaScript' src='allcarepos.js'></script>";
}
echo "</head>";
echo "<body bgcolor=\"#B9D6F0\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" scroll=\"no\">";
echo "<table id=\"Table_01\" width=\"1024\" height=\"768\"
border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td colspan=\"7\">";
echo "<img src=\"images/index_new_01.png\" width=\"1024\" height=\"122\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td rowspan=\"2\">";
echo "<img src=\"images/index_new_02.png\" width=\"444\" height=\"646\"></td>";
echo "<td>";
echo "<img src=\"images/index_new_03.png\" width=\"133\" height=\"29\"
border=\"0\" alt=\"Cash Register\" onClick=\"javascript: viewregister();\"></a></td>";
echo "<td>";
echo "<a href=\"reports/reports.php?cmd=Init\",\"reports\",\"toolbar=no,
scrollbars=yes,resizable=yes\"\" target=\"_blank\">
<img src=\"images/index_new_04.png\" width=\"98\" height=\"29\"
border=\"0\" alt=\"Reports Menu\"></a></td>";
echo "<td rowspan=\"2\">";
echo "<img src=\"images/index_new_05.png\" width=\"4\" height=\"646\"</td>";
echo "<td>";
echo "<a href=\"admin/admin.php\" target=\"_self\">";
echo "<img src=\"images/index_new_06.png\" width=\"89\" height=\"29\"
border=\"0\" alt=\"Administration\"></a></td>";
echo "<td>";
echo "<a href=\"index.php?req=logout\" target=\"_self\">
<img src=\"images/index_new_07.png\" width=\"116\" height=\"29\"
border=\"0\" alt=\"Logout\"></a></td>";
echo "<td rowspan=\"2\">";
echo "<img src=\"images/index_new_08.png\" width=\"140\" height=\"646\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\">";
echo "<img src=\"images/index_new_09.png\" width=\"231\" height=\"617\"></td>";
echo "<td colspan=\"2\">";
echo "<img src=\"images/index_new_10.png\" width=\"205\" height=\"617\"></td>";
echo "</tr>";
echo "</table>";
echo "<div id='dialogdiv'>"
."<div style='height: 700px; float : right; width : 500px;'>"
."</div></div>";
echo "</body>";
echo "</html>";
file: allcarepos.js
Section: Bottom of script (outputs the register html and makes some buttons)
if (!gotstoreinfo)
{
getstoreinfo();
if (gotstoreinfo)
{
window.onload=viewregister;
}
else
{
window.location = "index.php?req=noregister";
}
}
// @writedocument
document.write('<div id="register" class="register" style="' + cssRegister + '">'+
'<table border="0" cellspacing="0" cellpadding="1" style="' + cssRegister + '">' +
'<tr><td colspan="' + Width + '"align="right" class="titlebar" style="' + cssTitleBar + '">' +
'Current User: ' + currentuser +
'</td></tr>' +
'<tr>' +
'<td colspan="7" align="center">' +
'<div id="regstatus" style="' + cssStatus + '"></div>' +
'<div id="regdisplay" style="' + cssDisplay + '"></div>' +
'<div id="regsubtotal" style="' + cssSubTotal + '"></div>' +
'<div id="regtaxamount" style="' + cssSubTotal + '"></div>' +
'<div id="reginput" style="' + cssInput + '"></div>' +
'<div id="regtotal" style="' + cssTotal + '"></div>' +
'<div style="width:100%;height:10px;position:relative;top:0px;left:0px;"></div>' +
'</td><td colspan="4" align="center"><div id="RxSign" style="' + cssRxSign + '"></div>' +
'<div style="width:100%;height:50px;position:relative;top:0px;left:0px;"></div></td></tr>' +
'<tr>' + makebuttons() + '</tr></table></div>');
if(DOM)
{
obj = document.getElementById('register');
}
else if(IE4)
{
obj = document.all.register;
}
if(obj)
{
sobj = obj.style;
}
Same file - this is where I have my createwindow function:
function createwindow(parameters)
{
dialogopen=true;
var divid = parameters['divid'];
var title = parameters['title'];
var text = parameters['text'];
var width = "width=" + parameters['width'] + "px";
var height = "height=" + parameters['height'] + "px";
var resize = "resize=" + parameters['resize'];
var scrolling = "scrolling=" + parameters['scrolling'];
var center = "center=" + parameters['center'];
var settings = "'" + width + "," + height + "," + resize + "," + scrolling + "," + center + "'";
var mydiv = document.getElementById(divid);
var firstinput = parameters['firstinput'];
var myhtml = "";
myhtml+= ' <form action="" onsubmit="return false;" name="dialogform" id="dialogform" class="dialog">';
myhtml+= ' <table id="dialogtable" cellspacing="0">';
myhtml+= parameters['html'];
myhtml+= '</table>';
myhtml+= '</form>';
mydiv.innerHTML=myhtml;
dialog=dhtmlwindow.open('mywin', 'div', divid, title, settings);
document.getElementById(firstinput).value="";
document.getElementById(firstinput).focus();
}
Those last two lines don't work (except the first time the page loads) in IE, but work consistently in Firefox
Same file - a sample call to the createwindow function:
winparameters = {
divid: "dialogdiv",
title: "Receive on Account",
text: "Enter Account Name",
width: 250,
height: 200,
center: 1,
resize: 0,
scrolling: 0,
html: '<input type="text" size="30" tabindex="1" name="text1" value="" id="text1" maxlength="30"' +
'class="dialogform" onChange="ROA(this);" />'+
'<br>' +
'Medicaid?<input type="checkbox" class="bigcheck" id="sig" name="sig" tabindex="1" />' +
'<br>' +
'<input type="Submit" value="OK" class="dialogbutton" onClick="ROA(this);" />' +
'<input type="button" value="Cancel" class="dialogbutton" onClick="killwindow();" />',
firstinput: "text1"
}
createwindow(winparameters);
What am I doing wrong? Thanks in advance for any help. If it wasn't for the ActiveX support - I would have my users use FF, but I have to have support for IE.
Thanks,
LJ Wilson
DHTML Window Script
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm
3) Describe problem:
I have issues with setting the value property of text boxes and also with focus and onChange events. In Firefox, most things work fine. I can set the focus using
document.getElementById('text1').focus();
However, in IE - the first time the page loads, it will work, but after that - no worky. I imagine it has something to do with the method I am using to render html.
I also can use the onChange event in Firefox with no issues - IE ignores the ENTER key after changing the value in the textbox, the TAB key works, but not the ENTER key.
Here is a brief rundown of how I am rendering the html:
I have references to my main javascript on a PHP script (index.php). Using the window.onload event (in allcarepos.js) , I execute a function to get things started. Here is some of my code (I hope it is enough to help figure this out)
file: index.php
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
echo "<html xmlns='http://www.w3.org/1999/xhtml'>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />";
echo "<head>";
echo "<link rel=\"stylesheet\" href=\"css/selrow.css\" type=\"text/css\">";
echo "<link rel=\"stylesheet\" href=\"windowfiles/dhtmlwindow.css\" type=\"text/css\">";
echo "<link rel=\"stylesheet\" href=\"modalfiles/modal.css\" type=\"text/css\">";
echo "<link rel=\"stylesheet\" href=\"css/acpos.css\" type=\"text/css\">";
echo "<script type='text/javascript' src='xmlhttp.js'></script>";
echo "<script type='text/javascript' src='acpos_functions.js'></script>";
echo "<script type='text/javascript' src='windowfiles/dhtmlwindow.js'></script>";
echo "<script type='text/javascript' src='modalfiles/modal.js'></script>";
if ($_GET['req'] <> 'noregister')
{
echo "<script type='text/javaScript' src='allcarepos.js'></script>";
}
echo "</head>";
echo "<body bgcolor=\"#B9D6F0\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" scroll=\"no\">";
echo "<table id=\"Table_01\" width=\"1024\" height=\"768\"
border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td colspan=\"7\">";
echo "<img src=\"images/index_new_01.png\" width=\"1024\" height=\"122\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td rowspan=\"2\">";
echo "<img src=\"images/index_new_02.png\" width=\"444\" height=\"646\"></td>";
echo "<td>";
echo "<img src=\"images/index_new_03.png\" width=\"133\" height=\"29\"
border=\"0\" alt=\"Cash Register\" onClick=\"javascript: viewregister();\"></a></td>";
echo "<td>";
echo "<a href=\"reports/reports.php?cmd=Init\",\"reports\",\"toolbar=no,
scrollbars=yes,resizable=yes\"\" target=\"_blank\">
<img src=\"images/index_new_04.png\" width=\"98\" height=\"29\"
border=\"0\" alt=\"Reports Menu\"></a></td>";
echo "<td rowspan=\"2\">";
echo "<img src=\"images/index_new_05.png\" width=\"4\" height=\"646\"</td>";
echo "<td>";
echo "<a href=\"admin/admin.php\" target=\"_self\">";
echo "<img src=\"images/index_new_06.png\" width=\"89\" height=\"29\"
border=\"0\" alt=\"Administration\"></a></td>";
echo "<td>";
echo "<a href=\"index.php?req=logout\" target=\"_self\">
<img src=\"images/index_new_07.png\" width=\"116\" height=\"29\"
border=\"0\" alt=\"Logout\"></a></td>";
echo "<td rowspan=\"2\">";
echo "<img src=\"images/index_new_08.png\" width=\"140\" height=\"646\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\">";
echo "<img src=\"images/index_new_09.png\" width=\"231\" height=\"617\"></td>";
echo "<td colspan=\"2\">";
echo "<img src=\"images/index_new_10.png\" width=\"205\" height=\"617\"></td>";
echo "</tr>";
echo "</table>";
echo "<div id='dialogdiv'>"
."<div style='height: 700px; float : right; width : 500px;'>"
."</div></div>";
echo "</body>";
echo "</html>";
file: allcarepos.js
Section: Bottom of script (outputs the register html and makes some buttons)
if (!gotstoreinfo)
{
getstoreinfo();
if (gotstoreinfo)
{
window.onload=viewregister;
}
else
{
window.location = "index.php?req=noregister";
}
}
// @writedocument
document.write('<div id="register" class="register" style="' + cssRegister + '">'+
'<table border="0" cellspacing="0" cellpadding="1" style="' + cssRegister + '">' +
'<tr><td colspan="' + Width + '"align="right" class="titlebar" style="' + cssTitleBar + '">' +
'Current User: ' + currentuser +
'</td></tr>' +
'<tr>' +
'<td colspan="7" align="center">' +
'<div id="regstatus" style="' + cssStatus + '"></div>' +
'<div id="regdisplay" style="' + cssDisplay + '"></div>' +
'<div id="regsubtotal" style="' + cssSubTotal + '"></div>' +
'<div id="regtaxamount" style="' + cssSubTotal + '"></div>' +
'<div id="reginput" style="' + cssInput + '"></div>' +
'<div id="regtotal" style="' + cssTotal + '"></div>' +
'<div style="width:100%;height:10px;position:relative;top:0px;left:0px;"></div>' +
'</td><td colspan="4" align="center"><div id="RxSign" style="' + cssRxSign + '"></div>' +
'<div style="width:100%;height:50px;position:relative;top:0px;left:0px;"></div></td></tr>' +
'<tr>' + makebuttons() + '</tr></table></div>');
if(DOM)
{
obj = document.getElementById('register');
}
else if(IE4)
{
obj = document.all.register;
}
if(obj)
{
sobj = obj.style;
}
Same file - this is where I have my createwindow function:
function createwindow(parameters)
{
dialogopen=true;
var divid = parameters['divid'];
var title = parameters['title'];
var text = parameters['text'];
var width = "width=" + parameters['width'] + "px";
var height = "height=" + parameters['height'] + "px";
var resize = "resize=" + parameters['resize'];
var scrolling = "scrolling=" + parameters['scrolling'];
var center = "center=" + parameters['center'];
var settings = "'" + width + "," + height + "," + resize + "," + scrolling + "," + center + "'";
var mydiv = document.getElementById(divid);
var firstinput = parameters['firstinput'];
var myhtml = "";
myhtml+= ' <form action="" onsubmit="return false;" name="dialogform" id="dialogform" class="dialog">';
myhtml+= ' <table id="dialogtable" cellspacing="0">';
myhtml+= parameters['html'];
myhtml+= '</table>';
myhtml+= '</form>';
mydiv.innerHTML=myhtml;
dialog=dhtmlwindow.open('mywin', 'div', divid, title, settings);
document.getElementById(firstinput).value="";
document.getElementById(firstinput).focus();
}
Those last two lines don't work (except the first time the page loads) in IE, but work consistently in Firefox
Same file - a sample call to the createwindow function:
winparameters = {
divid: "dialogdiv",
title: "Receive on Account",
text: "Enter Account Name",
width: 250,
height: 200,
center: 1,
resize: 0,
scrolling: 0,
html: '<input type="text" size="30" tabindex="1" name="text1" value="" id="text1" maxlength="30"' +
'class="dialogform" onChange="ROA(this);" />'+
'<br>' +
'Medicaid?<input type="checkbox" class="bigcheck" id="sig" name="sig" tabindex="1" />' +
'<br>' +
'<input type="Submit" value="OK" class="dialogbutton" onClick="ROA(this);" />' +
'<input type="button" value="Cancel" class="dialogbutton" onClick="killwindow();" />',
firstinput: "text1"
}
createwindow(winparameters);
What am I doing wrong? Thanks in advance for any help. If it wasn't for the ActiveX support - I would have my users use FF, but I have to have support for IE.
Thanks,
LJ Wilson