Click here to Skip to main content
15,890,123 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
Questionupload photo Pin
pallavi shrivastava16-Sep-09 3:28
pallavi shrivastava16-Sep-09 3:28 
AnswerRe: upload photo Pin
EliottA16-Sep-09 6:10
EliottA16-Sep-09 6:10 
AnswerRe: upload photo Pin
Marc Firth17-Sep-09 14:37
Marc Firth17-Sep-09 14:37 
Questionsend email Pin
pallavi shrivastava15-Sep-09 2:59
pallavi shrivastava15-Sep-09 2:59 
AnswerRe: send email Pin
fly90415-Sep-09 7:42
fly90415-Sep-09 7:42 
QuestionGridview Pin
jaraldumary15-Sep-09 0:51
jaraldumary15-Sep-09 0:51 
AnswerRe: Gridview Pin
fly90415-Sep-09 7:34
fly90415-Sep-09 7:34 
AnswerRe: Gridview (caution, long answer) Pin
enhzflep15-Sep-09 14:56
enhzflep15-Sep-09 14:56 
I was playing with something the otherday that might be whhat you'r after.
It just displays a (dynamically generated, in this simple example) table, and allows editing by just double-clicking a cell.

<pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function makeEdit(tgtObj)
{
     tgtObj.ondblclick="";
     tgtObj.innerHTML = '<input class="myInput" type="text" value="' + tgtObj.innerHTML + '" />';
}

function makeSelect(tgtObj)
{
     var oldStr, newStr;
     oldStr = tgtObj.innerHTML;
     newStr = '<select class="myInput" name="select"><option value=0>0</option><option value=1>1</option></select>';
     tgtObj.ondblclick="";
     tgtObj.innerHTML = newStr;
}

// called by the ondblclick function of a table <td> </td> cell
function editModeOn()
{
     var curCol, btnIdStr="";
     var tgtRowObj = this.parentNode;
     var numCells = tgtRowObj.cells.length;
     var rand_no = Math.ceil(100*Math.random());
     btnIdStr = "btn_"; btnIdStr += rand_no;
     for (curCol=0; curCol<numCells-1; curCol++)
     {
          makeEdit(tgtRowObj.cells[curCol]);
     }
     tgtRowObj.cells[curCol].ondblclick = null;
     tgtRowObj.cells[numCells-1].innerHTML = "<input type='button' id='"+btnIdStr+"' value='save'/>";
//     tgtRowObj.cells[numCells-1].onclick=null;
     document.getElementById(btnIdStr).onclick=editModeOff;
}

function editModeOff()
{
     var str = "editModeOff: " + this.id;
     var parentCell = this.parentNode;
     var parentRow = parentCell.parentNode;
     var tgtObj = parentRow;
     var i, n, numCells, thisCell;
    
     numCells = tgtObj.cells.length;
     for (i=0; i<numCells-1; i++)
     {
          thisCell = tgtObj.cells[i];
          for (n=0; n<thisCell.childNodes.length; n++)
          {
               if (thisCell.childNodes[n].nodeType == document.ELEMENT_NODE)
               {
                    thisCell.innerHTML = tgtObj.cells[i].childNodes[n].value;
               }
               thisCell.ondblclick=editModeOn;
          }
     }
     tgtObj.cells[i].innerHTML = "BTN";
}

function makeTable(cols, rows, newTableId, tgtId)
{
     var y, x, str="", tgtObj = document.getElementById(tgtId);
     var width = 120;
    
     width *= cols;
    
     str = "<table style='table-layout:fixed;' width='"+width+"px' id='" + newTableId + "'>";
     for (y=0; y<rows; y++)
     {
          if (y%2 == 0)
               str += "<tr class='evenRow'>";
          else
               str += "<tr class='oddRow'>";
          for (x=0; x<cols; x++)
          {
               str += "<td>("+(x+1)+","+(y+1)+")</td>\n";
          }
          str += "</tr>";
     }
     str += "</table>";
     tgtObj.innerHTML = str;
     attachOnclickFunction(newTableId);
}

function attachOnclickFunction(tgtTblId)
{
     var tgtObj = document.getElementById(tgtTblId);

     var tabRows = document.getElementById(tgtTblId).rows;
     var curColNum, curRowNum;
     var curCell;
    
     for (curRowNum=0; curRowNum<tabRows.length; curRowNum++)
     {
          curRow = tabRows[curRowNum].cells;
          for (curColNum=0; curColNum<curRow.length; curColNum++)
          {
               curRow[curColNum].ondblclick = editModeOn; //showParentId;
               curRow[curColNum].className = "clickAble";
          }
     }
}

</script>

<style>
td{
     border-width: 1px;
     margin:0px;
     padding:0px;
     text-align: center;
     height: 1.5em;
     overflow:hidden;
}

.clickAble{
     cursor: pointer;
}
.highlightAble:hover{
     border-color:#00FF00;
     background-color:#F0FFF0;
}
.highlightAble:active{
     border-color:#FF0000;
     background-color:#FFF0F0;
}

.evenRow{ border-color:#00FF00; background-color:#FFFFFF; }
.evenRow:hover{     background-color:#E0FFE0; }
.evenRow:active{ background-color:#D0FFD0; }

.oddRow{ border-color:#FF0000; background-color:#F0F0F0; }
.oddRow:hover{     background-color:#E0FFE0; }
.oddRow:active{ background-color:#D0FFE0; }

.evenRow td{
     border-left-style:none;
     border-right-style:none;
     border-top-width: 1px;
     border-right-width: 1px;
     border-bottom-width: 1px;
     border-left-width: 1px;
     border-top-style: solid;
     border-bottom-style: solid;
     border-color: #CCCCCC;
}

table{
border-collapse: collapse;
}

.myInput{
     width: 99%;
     border-style:none;
     text-align:center;
}

.myInput:hover{
     background-color: #E0FFE0;
     font-weight: bold;
}
.myInput:focus{
     background-color: #D0FFD0;
     font-weight: bold;
}

</style>
</head>
<body onload="makeTable(10, 10, 'myTable', 'test1');">
<span id="test1"></span>
</body>
</html></pre>


S.
GeneralRe: Gridview (caution, long answer) Pin
fly90423-Sep-09 2:21
fly90423-Sep-09 2:21 
QuestionUnable to start yahoo messenger Pin
Vishal Kumar Soni14-Sep-09 10:24
Vishal Kumar Soni14-Sep-09 10:24 
QuestionProblem with PHP IDE Pin
sarang_k11-Sep-09 0:59
sarang_k11-Sep-09 0:59 
AnswerRe: Problem with PHP IDE Pin
Marc Firth11-Sep-09 5:40
Marc Firth11-Sep-09 5:40 
QuestionCURL Post Error [modified] Pin
LazyDragonfist7-Sep-09 4:08
LazyDragonfist7-Sep-09 4:08 
QuestionCreating visual content Pin
Sahir Shah2-Sep-09 23:02
Sahir Shah2-Sep-09 23:02 
AnswerRe: Creating visual content Pin
Marc Firth2-Sep-09 23:32
Marc Firth2-Sep-09 23:32 
AnswerRe: Creating visual content Pin
tagyurit13-Sep-09 10:50
tagyurit13-Sep-09 10:50 
QuestionNumeric value only Pin
udch2-Sep-09 22:03
udch2-Sep-09 22:03 
AnswerRe: Numeric value only Pin
Marc Firth2-Sep-09 23:17
Marc Firth2-Sep-09 23:17 
QuestionKubuntu updates [SOLVED] Pin
rastaVnuce2-Sep-09 4:35
rastaVnuce2-Sep-09 4:35 
Questionappache xampp server Pin
choudhari akash30-Aug-09 23:41
choudhari akash30-Aug-09 23:41 
AnswerRe: appache xampp server Pin
Marc Firth4-Sep-09 3:09
Marc Firth4-Sep-09 3:09 
AnswerRe: appache xampp server Pin
Jayapal Chandran26-Jul-10 8:04
Jayapal Chandran26-Jul-10 8:04 
QuestionErr: This is a marker file generated by the precompilation tool, and should not be deleted! Pin
lakshmichawala26-Aug-09 21:03
lakshmichawala26-Aug-09 21:03 
Questioni need to create a form with different userd id and names and then link it to the my sql database and lot more ------------------ need urgent help Pin
sean_198226-Aug-09 1:05
sean_198226-Aug-09 1:05 
AnswerRe: i need to create a form with different userd id and names and then link it to the my sql database and lot more ------------------ need urgent help Pin
kabirbdboy28-Aug-09 6:09
kabirbdboy28-Aug-09 6:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.