View Full Version : Linked selection box problem ...

10-03-2007, 11:51 PM
I need some help with a quick (I hope) change to a script.
The script is used to build a linked list selection box, which is working fine - except ...
I can't figure out how to get the Selected tag in the <option ...> to be set based on a $_GET value, so that the value selected doesn't disappear on a submit and redisplay.
I'm sure its really, stupidly easy, but Javascript is not really my bag !
Any help would be gratefully received.


I think its somewhere in here that need to change ...

function loadOptions(sParentBox, sChildBox)
//get the value of the selected option
var sParentValue = document.getElementById(sParentBox).value;
//load the appropriate event list to the option box
var theSel = document.getElementById(sChildBox);

//clear previous options
theSel.options.length = null;

//handle if there is no value
//if (sParentValue == ''){alert("exiting"); return;}

if (sParentBox == "range") {
oTargetArray = pp;
}else if(sParentBox == "pp"){
oTargetArray = box3;

//split the array values by the separator
var arrList = oTargetArray[sParentValue].split(",");

//loop thru the array of options to add them to the dropdown
for (x=0; x < arrList.length; x++)
var newOpt = new Option(arrList[x], arrList[x]);//(theText,theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;

function show_content(obj)
var op, s = [];
for (var i=0, len=obj.options.length; i<len; ++i)
op = obj.options[i];
if (op.selected) s[s.length] = op.text;
}//end func