By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

Drag and Drop from one dropdown listbox to another

P: 3
hi frnds,

I need ur help .im new to the javascript. i want to drag and drop an item from one dropdown listbox to an another dropdown listbox.i dont know how to do this. if possible means plz help me by giving ur suggestion
Jul 30 '08 #1
Share this Question
Share on Google+
6 Replies


RamananKalirajan
100+
P: 607
Sorry, I cant understand your requirement. You want drag and drop or there are two list box if you click an item in the 1st list box it must goes to the second list box. Pls post back ur requirement clearly.

Regards
Ramanan Kalirajan
Jul 30 '08 #2

RamananKalirajan
100+
P: 607
Just Try this and post whether this is the code you are looking for

[HTML]<html>
<head>
<script language="javascript">
function doThis()
{
var sel = document.getElementById('mySelect1').selectedIndex ;
var selObj = document.getElementById('mySelect1').options[sel].text;
document.getElementById('mySelect2').add(new Option(selObj,selObj))
}
</script>
</head>
<table>
<tr>
<td>
<select id="mySelect1" size="10" onclick="doThis()">
<option>Apple</option>
<option>Orange</option>
<option>Mango</option>
<option>Grape</option>
<option>Pine</option>
</select>
</td>
<td>
<select id="mySelect2"size="10" >
</select>
</td>
</tr>
</table>
</html>[/HTML]

Regards
Ramanan Kalirajan
Jul 30 '08 #3

acoder
Expert Mod 15k+
P: 16,027
i want to drag and drop an item from one dropdown listbox to an another dropdown listbox.
Is there a particular reason why you want drag/drop functionality? Can you not just use buttons instead?
Jul 30 '08 #4

P: 3
Is there a particular reason why you want drag/drop functionality? Can you not just use buttons instead?
in my clge they have given a task to transfer the item from one listbox to another listbox. while working , i got an idea to use the drag and drop method. but i dono how to do tats y i asked for help. pls give me ur idea on how to do it.
Jul 30 '08 #5

P: 3
in my clge they have given a task to transfer the item from one listbox to another listbox. while working , i got an idea to use the drag and drop method. but i dono how to do tats y i asked for help. pls give me ur idea on how to do it.

previously i tried this code. but this is not a good approach

[HTML]<html>
<head>
<script language="JavaScript">

function AddItem()
{
var i = document.getElementById('Combobox1').selectedIndex ;
var a = document.getElementById('Combobox1').options[i].text;
document.getElementById('Combobox2').add(new Option(a,a))
document.getElementById('Combobox1').remove(new Option(a,a))
}


</script>
</head>
<body>
<form>
<select name="Combobox1" id="Combobox1" onclick="AddItem()">
<option value="IName">Name</option>
<option value="Age">Age</option>
<option value="class">Class</option>
</select>
<select name="Combobox2" id="Combobox2">

</select> <br /><br />

</body>
</html>[/HTML]
Jul 30 '08 #6

acoder
Expert Mod 15k+
P: 16,027
Please use code tags when posting code. Thanks!

There's no need to make things complicated than they need to be. Just use a button to call a function to get the selected items from one list box to the other. Here's an example of what you might be looking for.
Jul 30 '08 #7

Post your reply

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