codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Re: Issue moving selected items from one list box to another...  Kjazwilty at 21:17 on Thursday, March 31, 2005
 

A bit hard tosay when you do not submit any code... oor browser type ..

Following are no problem in IE + FireFox:

<html>
<head>
<script language="JavaScript" type="text/javascript">
function moveItemx() {
var s_from = document.getElementById('s_from');
var s_to = document.getElementById('s_to');
var m_index = s_from.selectedIndex;
if(s_from.options.length && s_from.selectedIndex>-1)
{
s_to.options[s_to.length]= new Option(s_from.options[m_index].text,s_from.options[m_index].value );
s_from.options[m_index] = null;
}
}

</script>
</head>
<body>

<select size="5" id="s_from" ondblclick="moveItemx()">
<option value="op1">OPTION_1</option>
<option value="op2">OPTION_2</option>
<option value="op3">OPTION_3</option>
<option value="op4">OPTION_4</option>
<option value="op5">OPTION_5</option>
<option value="op6">OPTION_6</option>
<option value="op7">OPTION_7</option>
<option value="op8">OPTION_8</option>
<option value="op9">OPTION_9</option>
<option value="op10">OPTION_10</option>
<option value="op11">OPTION_11</option>
<option value="op12">OPTION_12</option>
</select>

<select size="5" id="s_to">
<option value="opc">OPTION_C</option>
</select>

<input type="button" onclick="javascript:moveItemx();" value="Move">

</body>

</html>

  Re: Issue moving selected items from one list box to another...  Kjazwilty at 21:33 on Thursday, March 31, 2005
 

- anyway i guess this helps:
(run after the element has ben removed)

for(i=s_from.length;i>=0;i--)
s_from.selectedIndex = i;

  Re: Issue moving selected items from one list box to another...  kbball1 at 14:13 on Friday, April 01, 2005
 

Sorry...it is in IE. Here is our Move function currently (I haven't tried any of your suggestions yet):

//***************************************************************
//* Function Name: move
//*
//* Description: This function moves the selected item from the
//* aobjFromSelect to the aobjToSelect. It then uses
//* aintToMaxCount and other attributes to set other
//* "state" information.
//*
//***************************************************************
function move(aobjFromSelect, aobjToSelect, aobjClickedButton, aobjOtherButton, aintToMaxCount)
{
var lobjOption = document.createElement("OPTION");
var lintFromIndex = aobjFromSelect.selectedIndex;
var lintToIndex;

lobjOption.value = aobjFromSelect.options(lintFromIndex).value;
lobjOption.text = aobjFromSelect.options(lintFromIndex).text;
aobjFromSelect.options.remove(lintFromIndex);

for (lintToIndex = 0; lintToIndex < aobjToSelect.options.length; lintToIndex++)
if (lobjOption.text < aobjToSelect.options(lintToIndex).text)
break;

aobjToSelect.options.add(lobjOption, lintToIndex);
aobjToSelect.selectedIndex = lintToIndex;

if (aobjOtherButton.disabled)
aobjOtherButton.disabled = false;

if (aobjFromSelect.options.length == 0)
{
if (aobjOtherButton.visible)
aobjOtherButton.focus();
//Null

aobjClickedButton.disabled = true;
}
else
{
if (lintFromIndex < aobjFromSelect.options.length)
aobjFromSelect.selectedIndex = lintFromIndex;
else
aobjFromSelect.selectedIndex = aobjFromSelect.options.length - 1;

if (aintToMaxCount > 0 && aobjToSelect.options.length == aintToMaxCount)
{
if (aobjOtherButton.visible)
aobjOtherButton.focus();

aobjClickedButton.disabled = true;
}
}

if (viewFields.homeOffView.value == "N" &&
(aobjFromSelect.name == "availableSecFirmCodes" ||
aobjToSelect.name == "availableSecFirmCodes"))
{
if (availableSecFirmCodes.options.length == 0)
{
secFirmAddAll.disabled = true;
}
else
{
secFirmAddAll.disabled = false;
}
}
return 0;

}








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: C++ Beginner question
•  Re: function within loop problem
•  moncler outlet
•  Re: Display swf file in pdf
•  Re: how to create forum using asp.net with c# language?
•  Discount coach store
•  Create Better Maps with Global Mapper
•  Re: How to display a message box when record is temporary stored in session/grid view
•  Sharing object in perl


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2012