Hi All,
Got me a stumper here. I have a form with a series of select boxes on them like
What I want to do is to allow users to add to the select option list by click an image, opening a little table and entering the new option. I have all that working, the form shows, captures the data to a js variable etc.
Where I am stumped is accessing the individual select boxes to be able to add the option via this code
I am playing with this code to access the elements but am geting stuck since it doesn't give any details about the object:
Bastien
I wish my computer would do what I want it to do,
instead of what I tell it to do...
Got me a stumper here. I have a form with a series of select boxes on them like
Code:
<SELECT NAME='COMPONENT_TYPE[]' ID='COMPONENT_TYPE[]' alt='Please enter a component type. If it's not in the list, add it by click the image next to the box'>
<option value='' SELECTED></option>...
What I want to do is to allow users to add to the select option list by click an image, opening a little table and entering the new option. I have all that working, the form shows, captures the data to a js variable etc.
Where I am stumped is accessing the individual select boxes to be able to add the option via this code
Code:
//add the actual option from the above function to the list
function addOption(theSel, theValue)
{
var newOpt = new Option(theValue, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
}
I am playing with this code to access the elements but am geting stuck since it doesn't give any details about the object:
Code:
function myfunction(value)
{
if(value.length<=0)
{
return false;
}else{
var x = sElement; //element passed by a 'this' in the inital function call
alert(sElement); //trying to get some details about the object
for (var i=0;i<x.length;i++)
{
addOption(sElement[x],value);
}
}
}
Bastien
I wish my computer would do what I want it to do,
instead of what I tell it to do...