设置多个组合框值

时间:2011-06-06 21:10:16

标签: javascript html combobox

我无法使用组合框来获取多个值。

这是我的一个有效的脚本:

function checkFont() {
   var cookie = readCookie("Font Family");
   fontFamily = cookie ? cookie : 'Century Gothic';
   document.getElementById('fonts').value = fontFamily;
   fontFace(fontFamily);
}

我的问题是使用一个脚本,其中组合框需要多个值。下面是我无法工作的脚本,非常感谢所有帮助!

请注意,组合框'colors'需要五个参数。

function checkBody() {
   var cookie1 = readCookie("Text Colour");
   textCol = cookie1 ? cookie1 : "#444";
   var cookie2 = readCookie("Background Colour");
   backCol = cookie2 ? cookie2 : "white";
   var cookie3 = readCookie("Link Colour");
   linkCol = cookie3 ? cookie3 : "#0424B5";
   var cookie4 = readCookie("Heading1 Colour");
   heading1Col = cookie4 ? cookie4 : "#0424B5";
   var cookie5 = readCookie("Headings Colour");
   headingsCol = cookie5 ? cookie5 : "#99975A";

   document.getElementById('colours').value = textCol,backCol,linkCol,heading1Col,headingsCol;
   bodyStyle(textCol,backCol,linkCol,heading1Col,headingsCol);
}

非常感谢!

1 个答案:

答案 0 :(得分:0)

我会尝试单独选择选项:

var theSelect = document.getElementById('colours')

for(i=0;i< theSelect.childNodes.length; i++){

    if(theSelect.childNodes[i].value == textCol || theSelect.childNodes[i].value = backColl ||<--etc. )
    { theSelect.childNodes[i].selected == true; }
}