开发者

Set multiple Combo box values

I'm having trouble getting a combo box to take multiple values.

This is one of my scripts which works:

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

My problem is doing that with a s开发者_运维问答cript where the combo box needs to take more than one value. Below is the script I can't get working, all help very much appreciated!

Note that the combo box 'colours' takes five parameters.

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);
}

Thanks very much in advance!


I would try selecting the options individually:

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; }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜