keywords.js
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:2k
- var cnt;
- cnt = 0;
- function addToList()
- {
- var pos;
- var i;
- sText = document.faqform.txtAdd.value.split(",");
- for(i=0;i<sText.length;i++)
- {
- if (!valid(sText[i]))
- return false;
- }
- for(i=0;i<sText.length;i++)
- {
- NewItem = new Option(sText[i],sText[i],false,false);
- pos = cnt;
- document.faqform.cmbAdd.options[pos]=NewItem;
- cnt++;
- }
- document.faqform.txtAdd.value = "";
- document.faqform.txtAdd.focus();
- return false;
- }
- function valid(wldBeVal)
- {
- if (wldBeVal == "")
- {
- alert("Please type in a value");
- return false;
- }
- invalidChars = new Array(" ", "!", "^","~","#","%","&","*","(",")","_","-","+","=","|","\","{","}",
- "[","]",";",":","'",""","<",">",",",".","?","/");
-
- for (j=0;j<invalidChars.length; j++)
- {
-
- if (wldBeVal.indexOf(invalidChars[j]) > -1)
- {
- alert("Invalid charactor '" + invalidChars[j] + "'");
- return false;
- }
- }
-
- if (compareStrings(wldBeVal))
- {
- return true;
- }
- else
- return false;
-
- return true;
- }
- function compareStrings(wldBeVal)
- {
- for (i=0;i<document.faqform.cmbAdd.options.length;i++)
- {
- if (document.faqform.cmbAdd.options[i].text == wldBeVal)
- {
- alert("The text '" + wldBeVal + "' has already been added...");
- return false;
- }
- }
- return true;
- }
- function removeFromList()
- {
- if (document.faqform.cmbAdd.selectedIndex == -1)
- {
- alert("Please select an item to remove");
- return false;
- }
- for (i=document.faqform.cmbAdd.options.length - 1;i>=0; i--)
- {
- if (document.faqform.cmbAdd.options[i].selected)
- {
- document.faqform.cmbAdd.options[i] = null;
- cnt--;
- }
- }
- return true;
- }
- function postThis()
- {
- var postVals;
- postVals = "";
- var Options;
- Options = document.faqform.cmbAdd.options;
- for (i=0; i < Options.length; i++)
- postVals = postVals == "" ? Options[i].text : postVals + "," + Options[i].text;
-
- document.faqform.hidListVals.value = postVals;
- return true;
- }
- function retrieveVals()
- {
- var Options;
- var listVals;
- var hidVals;
- Options = document.faqform.cmbAdd.options;
- hidVals = document.faqform.hidListVals.value;
- listVals = hidVals.split(",");
- if (hidVals != '')
- {
- for (i=0; i < listVals.length; i++)
- {
- NewItem = new Option(listVals[i],listVals[i],false,false);
- Options[i] = NewItem;
- }
- if (listVals.length > 0) cnt = listVals.length;
- }
- }