Hi all,
I have to design a page which looks like a table (Excel Sheet) in PHP., i.e. in the column part it has all the headers like PLExplanation, Date, BookName1, BookName2, BookName3, BookName4 etc. listed and in the row part it is having the row number. now the intersecting cell will contain the data. Upon Clicking that cell, user will be presented with a Menuwindow in which he can select the options Edit or Audit. In the menuwindow when you select edit option, the cell becomes editable and the user can change the value. But the cell is not becoming editable when the edit option is selected. I'm showing the code below for your reference. Please help me in this regard as it is very urgent for me.
Code:
<Script>
function displayMenu(thisobj) {
document.all.txthidden.value=thisobj.name;
contextMenu.style.leftPos+=10;
contextMenu.style.posLeft=event.clientX;
contextMenu.style.posTop=event.clientY;
contextMenu.style.display="";
contextMenu.setCapture();
}
function clickMenu() {
contextMenu.releaseCapture();
contextMenu.style.display="none";
el=event.srcElement;
document.all.mnuhidden.value=el.id;
if (el.id=="menuRiskEngine") {
doRiskEngine();
}
else if (el.id=="menuEdit") {
doEdit();
}
else if (el.id=="Audit") {
doAudit();
}
}
function doRiskEngine() {
alert('doRiskEngine');
}
function doEdit() {
var objstr='document.PLReportForm.'+document.PLReportForm.txthidden.value;
var obj=eval(objstr);
alert('value='+obj.value);
if (obj.readOnly == true){
obj.readOnly=false;
obj.className=obj.className+"b";
}
obj.focus();
obj.select();
}
function doAudit() {
alert('doAudit');
}
function switchMenu() {
el=event.srcElement;
if (el.className=="menuItem") {
el.className="highlightItem";
}
else if (el.className=="highlightItem") {
el.className="menuItem";
}
}
function changeType(thiscobj) {
if ((document.all.mnuhidden.value == "menuEdit") && (thiscobj.readOnly == false)){
//alert('menu = '+document.all.mnuhidden.value);
thiscobj.readOnly=true;
//alert(thiscobj.className+'-'+thiscobj.className+'-'+thiscobj.value);
thiscobj.className=thiscobj.className.substr(0,thiscobj.className.length-1);
}
}
function saveData(){
alert("Testing....");
}
</Script>
<html>
<head>
<title>CFXRisk P&L Reporting - Error</title>
<meta content="Evrsoft First Page" name="GENERATOR">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<style>
body {
padding-right: 0px;
padding-left: 0px;
padding-bottom: 0px;
margin: 0px;
overflow: hidden;
padding-top: 0px; }
html {
padding-right: 0px;
padding-left: 0px;
padding-bottom: 0px;
margin: 0px;
overflow: hidden;
padding-top: 0px; }
.menuItem {
font-family:ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
width:100%;
padding-left:16;
background-Color:menu;
color:black;
padding-top: 2px;
padding-bottom: 2px;
margin-bottom:0;
margin-top:0;
cursor: default; }
.menuItemDefault {
font-family:ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
font-weight:bold;
width:100%;
padding-left:16;
background-Color:menu;
color:black;
padding-top: 2px;
padding-bottom: 2px;
cursor: default; }
.highlightItem {
font-family:ms sans serif,helvetica,arial, sans-serif;
font-size:8pt;
width:100%;
padding-left:16;
background-Color:highlight;
color:white;
padding-top: 2px;
padding-bottom: 2px;
cursor: default; }
.textgry {
font-family:verdana,ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
background-Color:gray;
cursor: default;
width:280;
text-align:left;
border:none;}
.textgrn {
font-family:verdana,ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
background-Color:lightgreen;
cursor: default;
width:117;
text-align:right;
border:none;}
.textwht {
font-family:verdana,ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
background-Color:white;
cursor: default;
width:117;
text-align:right;
border:none;}
.texttit {
font-family:arial,verdana,ms sans serif,helvetica,sans-serif;
font-size:9pt;
color:#10659e;
background-Color:#dbeaf5;
cursor:default;
text-align:center;}
.textgryb {
font-family:verdana,ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
background-Color:gray;
cursor: wait;
width:280;
text-align:left;}
.textgrnb {
font-family:verdana,ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
background-Color:lightgreen;
cursor: wait;
width:117;
text-align:right;}
.textwhtb {
font-family:verdana,ms sans serif,helvetica,arial,sans-serif;
font-size:8pt;
background-Color:white;
cursor: wait;
width:117;
text-align:right;}
</style>
</head>
<body>
<?php
include("header.htm");
include("functions.php");
session_start();
header("Cache-control: private");
$dbh = db_connect();
$result = mysql_query("SELECT * FROM plsample", $dbh);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
?>
<form name=PLReportForm method=POST>
<div id=contextMenu onclick="clickMenu()"
onmouseover="switchMenu()"
onmouseout="switchMenu()"
style="position:absolute; display:none; width:130; background-Color:menu; border: 2px outset; ">
<div class="menuItem" id=menuRiskEngine>Risk Engine</div>
<div class="menuItem" id=menuEdit>Edit</div>
<div class="menuItem" id=Audit>Audit</div>
</div>
<h1 id="header"><a href="http://www.worldnet.ml.com"><img height="44" alt="Logo" src="images/gblmkts_logo.gif" width="117" align="absmiddle" vspace="-5" border="0"></a> CFXRisk - P&L Reporting</h1>
<table border="1" cellspacing="0" cellpadding="0" align:left style="border: 1 solid hidden">
<tr>
<td class=texttit> </td>
<td class=texttit> P/L Explaination</td>
<td class=texttit> 22 Feb</td>
<td class=texttit> OPEV </td>
<td class=texttit> OPSD </td>
<td class=texttit> OPSE </td>
<td class=texttit> OPAL </td>
<td class=texttit> OPPR </td>
</tr>
<?php
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$r=1;
$c=1;
echo "<tr><td class=texttit>" . $row['SlNo'] . "</td>";
echo "<td><input name=t$r$c type=text class=textgry onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['PLExplanation'] . "\" value=\"" . $row['PLExplanation'] . "\"></td>";
$c++;
echo "<td><input name=t$r$c type=text class=textgrn onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['COBDate'] . "\"value=" . $row['COBDate'] . "></td>";
$c++;
echo "<td><input name=t$r$c type=text class=textwht onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['OPEV'] . "\"value=" . $row['OPEV'] . "></td>";
$c++;
echo "<td><input name=t$r$c type=text class=textwht onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['OPSD'] . "\"value=" . $row['OPSD'] . "></td>";
$c++;
echo "<td><input name=t$r$c type=text class=textwht onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['OPSE'] . "\"value=" . $row['OPSE'] . "></td>";
$c++;
echo "<td><input name=t$r$c type=text class=textwht onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['OPAL'] . "\"value=" . $row['OPAL'] . "></td>";
$c++;
echo "<td><input name=t$r$c type=text class=textwht onblur=changeType(this) oncontextmenu=displayMenu(this) return false onclick=displayMenu(this) return false readonly ovalue=\"" . $row['OPPR'] . "\"value=" . $row['OPPR'] . "></td>";
echo "</tr>";
$r++;
}
?>
</table>
<input name="txthidden" type=hidden>
<input name="mnuhidden" type=hidden>
<table>
<tr></tr><tr></tr>
<tr><td align=center><input type="submit" value="Save" name="Submit1" class="button" onclick=saveData()></td>
<td align=center><input id="Reset1" type="reset" value="Cancel" name="Reset1" class="button" onclick=refresh(document.PLReportForm,"reset")></td></tr>
</table>
</form>
</body>
</html>
As you can see in the above code, the line of Code in red displays
"value=undefined" and the line in green is shows an error saying
"Object doesn't support this property or method". Please give me your valuable suggestion as to how this can be resolved.
chandru