469,289 Members | 2,228 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Drag and drop help needed: drag column data upwards and downwards


Its me sujith
i've done something with AJAX.

but for the rest i need someo ones help..

i've done half the work.

there are two tables. "ajax1" and "ajax2" (check db.sql)

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `ajax2` (
  2.   `id` int(11) NOT NULL auto_increment,
  3.   `id_ajax1` int(11) NOT NULL,
  4.   PRIMARY KEY  (`id`)
  5. );
  7. INSERT INTO `ajax2` VALUES (145, 4);
  9. CREATE TABLE `ajax1` (
  10.   `id` int(11) NOT NULL auto_increment,
  11.   `name` varchar(20) NOT NULL,
  12.   PRIMARY KEY  (`id`)
  13. );
  15. INSERT INTO `ajax1` VALUES (1, 'Habeeb');
  16. INSERT INTO `ajax1` VALUES (2, 'Sujith');
  17. INSERT INTO `ajax1` VALUES (3, 'Jeevan');
  18. INSERT INTO `ajax1` VALUES (4, 'Aditi');
  19. INSERT INTO `ajax1` VALUES (5, 'Ramu');
  20. INSERT INTO `ajax1` VALUES (6, 'Raghavan');

<script type="text/javascript">
var url = "testajax.php?aid=";
var url_remove = "testajax.php?act=rem&aid=";

function handleHttpResponse() {
if (http.readyState == 4) {
if(http.status==200) {
var results=http.responseText;
document.getElementById('divresult').innerHTML = results;

function request_table_ajax2_add(aid) {
http.open("GET", url+aid, true);
http.onreadystatechange = handleHttpResponse;

function request_table_ajax2_remove(aid) {
http.open("GET", url_remove+aid, true);
http.onreadystatechange = handleHttpResponse;

function getHTTPObject() {
var xmlhttp;
xmlhttp = new XMLHttpRequest();
else if (window.ActiveXObject){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (!xmlhttp){
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
return xmlhttp;

function request_table_ajax2_1() {
http.open("GET", url, true);
http.onreadystatechange = handleHttpResponse;

var http = getHTTPObject();
<div id="divresult"></div>
<script type="text/javascript">


mysql_connect("localhost", "username", "");
//mysql_connect("localhost", "username", "");
mysql_select_db("test") or die(mysql_error());
//mysql_select_db("db_ajax_habi") or die(mysql_error());

if(strlen(trim($_GET['aid']))>0) {
if($_GET['act']=='rem') {
$rem_query=mysql_query("DELETE FROM ajax2 WHERE id_ajax1=$_GET[aid]");
} else {
$get_query=mysql_query("SELECT * FROM ajax1 WHERE id=\"$_GET[aid]\"") or die(mysql_error());
if(mysql_num_rows($get_query) > 0) {
$add_query=mysql_query("INSERT ajax2(id_ajax1) VALUES(\"$_GET[aid]\")");

<table border="0" width="70%"><tr><td width="35%" valign="top">
$query=mysql_query("SELECT * FROM ajax1") or die(mysql_error());
$row = mysql_num_rows($query);
for($i = 0; $i < $row; $i++){
$name = mysql_result($query,$i,'name');
$id = mysql_result($query,$i,'id');
$query_ajax2=mysql_query("SELECT * FROM ajax2 WHERE id_ajax1=$id");
if(mysql_num_rows($query_ajax2) > 0 ) {
echo "<img name='aid' id='aid' src=\"images/icon2.gif\" onClick=\"request_table_ajax2_remove($id);\">&nbsp ;<font face='verdana' size='2'><b>$name</font><br>";
} else {
echo "<img name='aid' id='aid' src=\"images/icon1.gif\" onClick=\"request_table_ajax2_add($id);\">&nbsp;<f ont face='verdana' size='2'><b>$name</font><br>";

</td><td width="35%" valign="top">
$query1=mysql_query("SELECT * FROM ajax2") or die(mysql_error());

$id=mysql_result($query1, $i, 'id_ajax1');
$query2=mysql_query("SELECT name FROM ajax1 WHERE id=$id") or die(mysql_error());

$name1 = mysql_result($query2,$j,'name');
echo "<font face='verdana' size='2' color='red'><b>$name1</b></font><br />";
Now i can do the clicking process.

im able to add data to table "ajax2" from table "ajax1" by clickin on the "add" button.
deletion also possible.

But now my problem is drag and drop.

i need to drag data in the second column (ie; the result of clicked items) upwards and downwards..
but im not able to do it..
can u plz halp me to do that??

run it on Mozilla firefox..
then u will understand my problem..

plz help me..
Nov 29 '06 #1
1 1472
16,027 Expert Mod 8TB
This link may help. You may also find this howto useful.
May 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by SamSpade | last post: by
3 posts views Thread by Ajay Krishnan Thampi | last post: by
1 post views Thread by Ramesh Chawla | last post: by
19 posts views Thread by Owen T. Soroke | last post: by
3 posts views Thread by VB Programmer | last post: by
1 post views Thread by Darren | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.