IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
Topic
  • 1 reply
  • Latest Post - ‏2014-09-20T11:03:30Z by jitupkp
little_john
little_john
2 Posts

Pinned topic quick edit without scrolling

‏2012-04-22T13:57:42Z |
Hi, I'd like to edit database with quickedit, the script is work fine if in the first page, but if in the other page it go to top page again when I click on it. How to fix so it won't reload to the top page.

Here is the main :

<html>
<head>

<script language="javascript" src="calendar.js"></script>
<script language="JavaScript" type="text/JavaScript">

function inputShow(id1,id2)
{
document.getElementById(id1).innerHTML=" ";
document.getElementById(id2).type="text";
document.getElementById(id2).focus();
}
function hide(id1,id2,val)
{
document.getElementById(id1).type="hidden";
document.getElementById(id2).innerHTML=""+val;
}
function enter(event,name,id,noid)
{
if (event.keyCode==13)
{
berubah(name,id,noid);
}
}
function berubah(name,id,noid) {
var xmlHttp=XMLHttpRequest();
var field=new String(name);
var val=new String(document.getElementById(id).value);
var url="editdata.php";
url1=url+"?noid="+noid;
url2=url1+"&field="+field;
url3=url2+"&value="+val;
xmlHttp.open("GET",url3,true);
xmlHttp.send(null);
window.location.reload();
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
<style type="text/css">
th.judul { width:250px; }
{
text-decoration : none;
font-family : Tahoma;
font-size : 9pt;
color : #000000;
}
</style>

</head>

<body>
<table border="1" cellspacing="0">
<th width="15" class="judul">No</th>
<th class="judul">Nomor Kira</th>
<th class="judul">Nomor Kira X</th>
<th class="judul">Pakai</th>
<?php
$koneksi=mysql_connect("localhost","root","") or die ("Gagal konek server".mysql_error());
if ($koneksi) {
mysql_select_db("cantique",$koneksi) or die ("Database gagal dibuka".mysql_error());
$qry=mysql_query("SELECT no_urut,no_kira,no_kira_x,pakai FROM mutasi_dtl_temp ORDER BY no_urut ASC");
$no=1;
while ($data1=mysql_fetch_array($qry)) {
echo "
<tr>
<td>$no</td>
<td><a href='#' id='anchorno_kira$no' ondblClick=\"inputShow(this.id,'no_kira$no')\">$data1no_kira</a>
<input type='hidden' size='30' value='$data1no_kira' id='no_kira$no' name='no_kira'
onBlur=\"hide(this.id,'anchorno_kira$no','$data1no_kira')\" onKeyUp=\"enter(event,this.name,this.id,$data1no_urut)\" /></td>

<td><a href='#' id='anchorno_kira_x$no' ondblClick=\"inputShow(this.id,'no_kira_x$no')\">$data1no_kira_x</a>
<input type='hidden' size='30' value='$data1no_kira_x' id='no_kira_x$no' name='no_kira_x'

onBlur=\"hide(this.id,'anchorno_kira_x$no','$data1no_kira_x')\" onKeyUp=\"enter(event,this.name,this.id,$data1no_urut)\" /></td>

<td><a href='#' id='anchorpakai$no' ondblClick=\"inputShow(this.id,'pakai$no')\">$data1pakai</a>
<input type='hidden' size='30' value='$data1pakai' id='pakai$no' name='pakai'

onBlur=\"hide(this.id,'anchorpakai$no','$data1pakai')\" onKeyUp=\"enter(event,this.name,this.id,$data1no_urut)\" /></td>

</tr>";
$no++;
}
}

?>
</table>
</body>

</html>

And this is "editdata.php" :
<?php
mysql_connect("localhost","root","");
mysql_select_db("cantique");
$noid=$_GET;
$field=$_GET;
$value=$_GET;
mysql_query("UPDATE mutasi_dtl_temp SET $field='$value' where no_urut='$noid'");
?>

Thanks in advance.