javascript对象机制
var currItem = listbox.options[currIndex];
var prevItem = listbox.options[currIndex - 1];
//alert(currItem);
alert(prevItem.text);
listbox.options[currIndex - 1].text = currItem.text;
listbox.options[currIndex - 1].value = currItem.value;
alert(prevItem.text); //两次alert值是不同的
listbox.options[currIndex].text = prevItem.text;
listbox.options[currIndex].value = prevItem.value;
相关文档:
我们在jsp页面上的js脚本中可以调研java代码,比如,我们需要再js中用alert函数显示服务器端发送过来的某个字符串那么我们可以这样做
tomcat下:
在服务器端我们有request.setAttribute("name","abc");
那么我要在页面上用alert显示的话,有两种方式:
1、使用EL表达式
在El表达式的外面用引号即可:
<scri ......
<script type="text/javascript">
window.onbeforeunload=function()
{
alert("onbeforeunload event...");
//return false;
}
</script>
<a href="#" onclick="return true;">测试1</a><br/>
<a href="javascript:void(0)" onclick="return true;">测试2</a><br/& ......
<script >
function showimage()
{
//IMG1为图片控件或Div,File1为上传文件控件
document.getElementById("IMG1"). src = document.getElementById("File1").value;
}
</script >
控件中引用:
<input id="File1" runat="server" type="file" onc ......
<script type="text/javascript">
function dayChange(year,month,day){
var selectYear = document.getElementById(year);
var selectMonth = document.getElementById(month);
var selectDay = document.getElementById(day);
va ......