That's exactly what I mean. I've set up a database. I'm just building an interface to it. There is a bank of items, I would like the users to be able to use the method that you have described to move stuff arround...
So, you already have your web page populating the listboxes from tables in the database? If so, then it's a matter of juggling the table contents, then telling your page to refresah the listboxes, right?
Cheers,
Edward
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
I must think on this, but part of that thinking will be going over: faq216-335
So, you might want to see if that's helpful to you. I've been trying to bullwhip this same functionality on a project of my own and haven't been terribly successful.
I'll let you know if I figure it out, but if someone else has, I hope they mention it here.
Cheers,
Edward
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
there is a simple little way to do this that is cross browser.
Here is the jist of it. Something to make you guys wonder about what else I will come up with! I'll be coding something better but that can probably give you guys an idea while I code something else!
<HTML>
<HEAD>
<SCRIPT>
function moveOption(sourceSelect, targetSelect, index)
{
var index = (index == null) ? sourceSelect.selectedIndex : -1 ;
if (index == -1)
{
alert("Please select one item to move"
return
}
var option = sourceSelect.options[index]
var temp = new Option(option.text, option.value)
sourceSelect.options[index] = null
targetSelect.options[targetSelect.options.length] = temp
}
Ok so here is another similar script that is more flexible. You can have multiple options selected or just a single one!
I hope you guys enjoy this!
<HTML>
<HEAD>
<SCRIPT>
function moveOption(sourceSelect, targetSelect)
{
var index = new Array()
for (var i = 0; i < sourceSelect.options.length; i++)
{
if (sourceSelect.options.selected)
{
index.push(i)
}
}
if (index.lenght == 0)
{
alert("Please select at least one item to move"
return
}
while(index.length != 0)
{
var i = index.pop()
var option = sourceSelect.options
var temp = new Option(option.text, option.value)
sourceSelect.options = null
targetSelect.options[targetSelect.options.length] = temp
}
}
<HTML>
<HEAD>
<SCRIPT>
function moveOption(sourceSelect, targetSelect)
{
var index = new Array()
for (var i = 0; i < sourceSelect.options.length; i++)
{
if (sourceSelect.options.selected)
{
index.push(i)
}
}
if (index.lenght == 0)
{
alert("Please select at least one item to move"
return
}
while(index.length != 0)
{
var i = index.pop()
var option = sourceSelect.options
var temp = new Option(option.text, option.value)
sourceSelect.options = null
targetSelect.options[targetSelect.options.length] = temp
}
}
Once I've moved some options over to the new select, the same number of options are highlighted in the old (highlighing values that have now moved up into the old positions)... What's the best way to prevent this highlighting?
I often find myself challenged with how to do things. Yet I try not to post for an answer ( being relatively new to javascript I find that I can retain the lesson better when I figure out things by working them out ) however, I would not be able to overcome the problems if it was not for the input that you and others do in this forum that gives me a path to follow. That and referring to the books! (*) you deserve it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.