Jun
18
公司的论坛需要频道页,上面涉及到了一些小功能的增加。
用到了较多的select控件来控制一些搜索之类的。级联倒是没用到,基本的操作做下记录
JS取select中option的值
var sel = document.getElementById("waterpost");
var m=sel.options[sel.selectedIndex].value;
取select中option的文字
var sel = document.getElementById("waterpost");
var m=sel.options[sel.selectedIndex].text;
js改变form表单中action地址
很简单,就是如此
document.getElementById("bearpost").action="thread.php?fid=2&modelid=20";
js检查form表单中的值
if(document.bearpost.waterpost.value == "0"){
alert("请选择搜索性别!");
return false;
}
}
判断表单bearpost中name为waterpost的控件为0就弹出警告
form则要写入 onSubmit="return CheckForm();"来促发事件
那JS如何改变选中项的值呢?
objSelect.options[objSelect.selectedIndex] = new Option("你好","hello");
对象一样用getElementById来获得
用到了较多的select控件来控制一些搜索之类的。级联倒是没用到,基本的操作做下记录
JS取select中option的值
var sel = document.getElementById("waterpost");
var m=sel.options[sel.selectedIndex].value;
取select中option的文字
var sel = document.getElementById("waterpost");
var m=sel.options[sel.selectedIndex].text;
js改变form表单中action地址
很简单,就是如此
document.getElementById("bearpost").action="thread.php?fid=2&modelid=20";
js检查form表单中的值
if(document.bearpost.waterpost.value == "0"){
alert("请选择搜索性别!");
return false;
}
}
判断表单bearpost中name为waterpost的控件为0就弹出警告
form则要写入 onSubmit="return CheckForm();"来促发事件
那JS如何改变选中项的值呢?
objSelect.options[objSelect.selectedIndex] = new Option("你好","hello");
对象一样用getElementById来获得



传说能打败flash的j
js来输出日期
