Advertisement
Eather

solution for shawon

Apr 12th, 2012
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.03 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Account group</title>
  6.         <link type="text/css" rel="stylesheet" href="css/all.css" />
  7.         <script type="text/javascript" src="js/jquery/jquery-1.2.1.pack.js"></script>
  8.         <script type="text/javascript" src="js/jquery/jquery.populate.js"></script>
  9.         <script type="text/javascript" src="js/populate-page-functions.js"></script>
  10.          <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  11.     <script type="text/javascript">
  12. function getValue(a,b)
  13.   {
  14.   document.getElementById("sd1").value=a;
  15.   document.getElementById("sd2").value=b;
  16.   }
  17. function addRow(id){
  18.     var x = document.getElementById("sd1").value;
  19.     var y = document.getElementById("sd2").value;
  20.    
  21.     if( ($('#'+x).text()==''?0:1)==1)
  22.     {
  23.         $('#'+x).text(y);
  24.     }
  25.     else{
  26. var tbody = document.getElementById(id).getElementsByTagName("tbody")[0];
  27. var row = document.createElement("tr");
  28. var data1 = document.createElement("td");
  29. data1.appendChild(document.createTextNode($('#sd1').val()));
  30. var data2 = document.createElement("td");
  31.  
  32. data2.appendChild(document.createTextNode($('#sd2').val()));
  33. row.appendChild(data1);
  34. row.appendChild(data2);
  35. tbody.appendChild(row);
  36.     }
  37. }
  38.  
  39. </script>
  40. <script src="js/ajaxsbmt.js" type="text/javascript"></script>
  41. </head>
  42.  
  43. <body>
  44.         <table width="500" border="0" bordercolor="#000000">
  45. <tr height="10" bgcolor="#CCFFFF">
  46.   <th align="left" valign="top" width="50%"><form name="MyForm" method="post" onsubmit="return false;"> <input type="text" name="s" id="sd1" required>
  47. <input type="text" name="sd" id="sd2" required>
  48. <input name="send_button" type="submit" value="Send" onclick="javascript:addRow('dataTable')" /></form></th>
  49.   <th align="left" valign="top" width="50%" ><?php
  50. $con = mysql_connect("localhost","root","");
  51. if (!$con)
  52.   {
  53.   die('Could not connect: ' . mysql_error());
  54.   }
  55.  
  56. mysql_select_db("account", $con);
  57. $result = mysql_query("SELECT * FROM accountgroup");
  58. ?>
  59. <div style="height: 300px; overflow:auto; overflow-y:auto;  ">
  60. <table width="100%" border="0" bordercolor="#000000" id="dataTable">
  61. <tbody>
  62. <tr height="10" bgcolor="#CCFFFF">
  63.   <th align="left" valign="top" bgcolor="#0000FF">Group Code</th>
  64.   <th align="left" valign="top" bgcolor="#0000FF">Group Name</th>
  65. </tr>
  66.  
  67. <?php
  68. $num=mysql_numrows($result);
  69. $i=0;
  70. while ($i < $num) {
  71. $f1=mysql_result($result,$i,"GroupID");
  72. $f2=mysql_result($result,$i,"GroupName");
  73. ?>
  74.  
  75. <tr bgcolor="#CCFFFF" onDblClick="getValue('<?php echo $f1; ?>','<?php echo $f2; ?>')">
  76. <td valign="top" bgcolor="#99FFFF" ><?php echo $f1; ?></td>
  77. <td valign="top" bgcolor="#99FFFF" id='<?php echo $f1;?>'><?php echo $f2; ?></td>
  78. </tr>
  79.  
  80. <?php
  81. $i++;
  82. }
  83.  
  84. ?>
  85. </tbody></table></div></th>
  86. </tr>
  87.  
  88. </table>
  89. </body>
  90. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement