CreateCode
<script language="javascript">
//生成代碼
function createCode()
{
totalheight = parseInt(fcreate.bodyheight.value) + fcreate.headheight.value * (fcreate.itemcount.value - 1);
textCode.value = text1.value +
"var headHeight = " + fcreate.headheight.value + ";" +
"var bodyHeight = " + fcreate.bodyheight.value + ";" +
"var objcount = " + fcreate.itemcount.value + ";" +
"var step = " + fcreate.mspeed.value + ";" +
text2.value +
".headtd1 { background: #" + fcreate.headcolorn.value + "; border: 2px outset; border-color: #" + fcreate.lbordern.value + " #" + fcreate.dbordern.value + " #" + fcreate.dbordern.value + " #" + fcreate.lbordern.value + "; cursor: hand; font-size: 9pt}" +
".headtd2 { background: #" + fcreate.headcolora.value + "; border: 2px outset; border-color: #" + fcreate.lbordera.value + " #" + fcreate.dbordera.value + " #" + fcreate.dbordera.value + " #" + fcreate.lbordera.value + "; cursor: hand; font-size: 9pt}" +
".bodytd { background: #" + fcreate.bodycolor.value + "; border: 2px outset; border-color: #" + fcreate.lborderb.value + " #" + fcreate.dborderb.value + " #" + fcreate.dborderb.value + " #" + fcreate.lborderb.value + "; font-size: 9pt}" +
text3.value +
"
";
itemtop = 0;
for (i = 1; i <= parseInt(fcreate.itemcount.value); i++)
{
textCode.value += "
" +
"
" +
"" +
"";
//textCode.value += getValue("fcreate.item" + i);
textCode.value +=document.all["item"+i].value+" | "+
"
" +
"" +
"" +
"test" +
" | " +
"
" +
"
" +
"
";
if (i == 1)
itemtop += parseInt(fcreate.bodyheight.value);
else itemtop += parseInt(fcreate.headheight.value);
}
textCode.value += "
"
}
//獲取對象的值
function getValue(obj)
{
//obj = Object(obj);
return obj.value;
}
//清空代碼
function clearCode()
{
textCode.value = "";
}
//預(yù)覽代碼
function prevCode()
{
createCode();
open().document.write(textCode.value);
}
//選擇代碼
function selectCode()
{
textCode.select();
}
//根據(jù)輸入的數(shù)字,自動生成子菜單的填寫項
function checkItems()
{
if ((fcreate.itemcount.value.length > 0 && isNaN(fcreate.itemcount.value)) || fcreate.itemcount.value.length == 0)
{
alert("請輸入數(shù)字!");
fcreate.itemcount.focus();
}
else
{
if (fcreate.itemcount.value > 50)
{
alert("太夸張了吧,小一點呀,不用這么玩命吧?。?0以下,含50)")
fcreate.itemcount.focus();
return;
}
if (fcreate.itemcount.value < 1)
{
alert("太夸張了吧,一個不要你要做什么!(1以上,含1)")
fcreate.itemcount.focus();
return;
}
itemtext = "
"
document.all.itemmenu.innerHTML = itemtext;
}
}
//檢查是否是一個合法的顏色數(shù)值
function changebkclr(obj)
{
hexv = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
flag = false;
if (obj.value.length != 6)
{
alert("請用正確填寫!(六位數(shù))");
obj.focus();
}
else
{
for (i = 0; i < 6; i++)
{
for (j = 0; j <16; j++)
if (obj.value.charAt(i).toLowerCase() == hexv[j])
flag = true;
if (!flag)
{
alert("請用十六進制填寫。(0-9,a-f)");
obj.focus();
return;
}
flag = false;
}
obj.style.background=obj.value;
}
}
//檢查是否是一個合法的數(shù)字
function checknum(obj)
{
if (isNaN(obj.value))
{
alert("請輸入數(shù)字!");
obj.focus();
return;
}
}
//檢查改變數(shù)值的速度合法性
function changespd(obj)
{
fcreate.mspeed.value = 1;
}
//檢查是否是一個合法的速度
function checkspeed(obj)
{
if (isNaN(obj.value))
{
alert("請輸入數(shù)字!");
obj.focus();
}
else
{
if ((obj.form.bodyheight.value - obj.form.headheight.value)%obj.value != 0)
{
alert("請確認可以被 “菜單體高度 - 菜單題頭高度” 整除");
obj.focus();
}
}
}
//控制總題目的填寫
function ctrltitle(obj)
{
if (obj.value == "有")
obj.form.titlename.disabled = false;
else
obj.form.titlename.disabled = true;
}
</script>