johnt
05-28-2003, 03:11 PM
Bit of a problem getting the following to work in IE 5.2 on a Mac. The script is supposed to populate a field with comma separated values taken from a multiple select field. Anyone any ideas?
<html>
<head>
<SCRIPT>
function setVal(list,f) {
__result="";
__for (i=0;i<list.options.length;i++) {
____if (list.options[i].selected) {
______result+=list.options[i].text+", ";
____}
__}
__result=result.substring(0,result.length-2);
__f.elements['table.color'].value=result;
}
</SCRIPT>
</head>
<body bgcolor="#ffffff">
<FORM>
<SELECT NAME="colorlist" SIZE=5 MULTIPLE onChange="setVal(this,form)">
<OPTION>Red</OPTION>
<OPTION>Orange</OPTION>
<OPTION>Yellow</OPTION>
<OPTION>Green</OPTION>
<OPTION>Blue</OPTION>
<OPTION>Violet</OPTION>
</SELECT>
<INPUT TYPE=TEXT NAME="table.color">
</FORM>
</body>
</html>
<html>
<head>
<SCRIPT>
function setVal(list,f) {
__result="";
__for (i=0;i<list.options.length;i++) {
____if (list.options[i].selected) {
______result+=list.options[i].text+", ";
____}
__}
__result=result.substring(0,result.length-2);
__f.elements['table.color'].value=result;
}
</SCRIPT>
</head>
<body bgcolor="#ffffff">
<FORM>
<SELECT NAME="colorlist" SIZE=5 MULTIPLE onChange="setVal(this,form)">
<OPTION>Red</OPTION>
<OPTION>Orange</OPTION>
<OPTION>Yellow</OPTION>
<OPTION>Green</OPTION>
<OPTION>Blue</OPTION>
<OPTION>Violet</OPTION>
</SELECT>
<INPUT TYPE=TEXT NAME="table.color">
</FORM>
</body>
</html>