473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

HIii...

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)

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. );
  6.  
  7. INSERT INTO `ajax2` VALUES (145, 4);
  8.  
  9. CREATE TABLE `ajax1` (
  10.   `id` int(11) NOT NULL auto_increment,
  11.   `name` varchar(20) NOT NULL,
  12.   PRIMARY KEY  (`id`)
  13. );
  14.  
  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');
  21.  
ad.html

[HTML]<html>
<head>
<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;
http.send(null);
}

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

function getHTTPObject() {
var xmlhttp;
if(window.XMLHttpRequest){
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;
http.send(null);
}

var http = getHTTPObject();
</script>
</head>
<body>
<div id="divresult"></div>
<script type="text/javascript">
request_table_ajax2_1();
</script>
</body>
</html>
[/HTML]


testajax.php

[PHP]<?php
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">
<?php
$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">
<?php
$query1=mysql_query("SELECT * FROM ajax2") or die(mysql_error());

if(mysql_num_rows($query1)>0){
for($i=0;$i<mysql_num_rows($query1);$i++){
$id=mysql_result($query1, $i, 'id_ajax1');
$query2=mysql_query("SELECT name FROM ajax1 WHERE id=$id") or die(mysql_error());

if(mysql_num_rows($query2)>0){
for($j=0;$j<mysql_num_rows($query2);$j++){
$name1 = mysql_result($query2,$j,'name');
echo "<font face='verdana' size='2' color='red'><b>$name1</b></font><br />";
}
}
}
}
?>
</td></tr></table>
[/PHP]
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 1628
acoder
16,027 Expert Mod 8TB
This link may help. You may also find this howto useful.
May 31 '08 #2

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

Similar topics

1
by: Targa | last post by:
I have an ASP scheduling application in which there are blocks of time, represented with a table, within another table which is the timeline. In other words, I have a table with a vertical...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
1
by: Ramesh Chawla | last post by:
Hi, I have to implement the functionality like 'drag n drop' in asp.net form. It is like, a table will be shown to the user at the client side. the first and last column of the table at the client...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
1
by: Darren | last post by:
I'm trying to create a file using drag and drop. I want to be able to select a listview item drag it to the shell and create a file. Each icon in the listview represents a blob in a database. When...
2
by: amitsaxena1981 | last post by:
hi, I am using asp.net2.0 with vb.net , I have to create gridview user control and I want to drag and drop a record to a different position in the same Gridview using AJAX .Is it possible to...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.