Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic select form add to list

Status
Not open for further replies.

drway

Programmer
Jun 27, 2007
2
GB
hi there,

im working on a dynamic select form combo function, which allows u to add values from one select list to another but i need some help to make the form process the values, they show up but arent being submitted! im a novice with javascript so a bit lost.

the script im using is like this:
picked=[]; // global array to remember selected items
function add2list(sourceID,targetID){
source=document.getElementById(sourceID);
target=document.getElementById(targetID);
numberOfItems=source.options.length;
insertPt=target.options.length; // insert at end
if (target.options[0].text==="") {insertPt=0;} // null option fix
for (i=0;i<numberOfItems;i++){
if(source.options.selected===true && picked!==true){
msg=source.options.text;
target.options[insertPt]=option;
picked=true;insertPt=target.options.length;
}
}
}
curr = 0;
function takefromlist(targetID)
{
target = document.getElementById(targetID);
// insert code to test to see if the box has options
// if it does not, return no value
for(var i = (target.options.length - 1); i >= 0; i--)
{
if(target.options.selected){target.options = null;curr--;}
}
}

 
sorry i left out a bit:
picked=[]; // global array to remember selected items
function add2list(sourceID,targetID){
source=document.getElementById(sourceID);
target=document.getElementById(targetID);
numberOfItems=source.options.length;
insertPt=target.options.length; // insert at end
if (target.options[0].text==="") {insertPt=0;} // null option fix
for (i=0;i<numberOfItems;i++){
if(source.options.selected===true && picked!==true){
msg=source.options.text;
target.options[insertPt]=new Option(msg);
picked=true;insertPt=target.options.length;
}
}
}
curr = 0;
function takefromlist(targetID)
{
target = document.getElementById(targetID);
// insert code to test to see if the box has options
// if it does not, return no value
for(var i = (target.options.length - 1); i >= 0; i--)
{
if(target.options.selected){target.options = null;curr--;}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top