JavaScript的onchange事件
<selectname="status"><option>New<option>Pending<option>Complete</select><inputtype="t...
<select name="status" ><option >New<option >Pending<option >Complete</select>
<input type="text" name="completeddate" value="" size=30 readonly="readonly" />当选到了Complete时候 文本域会自动出现当天的日期 怎么使用JavaScript实现? 急急急啊 展开
<input type="text" name="completeddate" value="" size=30 readonly="readonly" />当选到了Complete时候 文本域会自动出现当天的日期 怎么使用JavaScript实现? 急急急啊 展开
展开全部
楼上兄台思路很正确不过貌似忘加了点什么.
select 标签要记得赋值
<select name="status" onchange="showTime(this)">
<option value="New">New</option>
<option value="Pending">Pending</option>
<option value="Complete">Complete</option>
</select>
脚本:
<script language="javascript">
function showTime(obj){
if(obj.value=="Complete"){
//这里直接用new Date()的话显示的会比较难看,可以转化一下
//document.getElementById("completeddate").value=new Date();
var date = new Date();
var newDate = date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
document.getElementById("completeddate").value = newDate
}
}
</script>
select 标签要记得赋值
<select name="status" onchange="showTime(this)">
<option value="New">New</option>
<option value="Pending">Pending</option>
<option value="Complete">Complete</option>
</select>
脚本:
<script language="javascript">
function showTime(obj){
if(obj.value=="Complete"){
//这里直接用new Date()的话显示的会比较难看,可以转化一下
//document.getElementById("completeddate").value=new Date();
var date = new Date();
var newDate = date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
document.getElementById("completeddate").value = newDate
}
}
</script>
展开全部
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>无标题文档</title>
<script language="javascript">
function showTime(obj){
if(obj.value=="Complete"){
document.getElementById("completeddate").value=new Date();
}
}
</script>
</head>
<body>
<select name="status" onchange="showTime(this)">
<option>New
<option>Pending
<option>Complete
</select>
<input type="text" id="completeddate" name="completeddate" value="" size=30 readonly="readonly"/>
</body>
</html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>无标题文档</title>
<script language="javascript">
function showTime(obj){
if(obj.value=="Complete"){
document.getElementById("completeddate").value=new Date();
}
}
</script>
</head>
<body>
<select name="status" onchange="showTime(this)">
<option>New
<option>Pending
<option>Complete
</select>
<input type="text" id="completeddate" name="completeddate" value="" size=30 readonly="readonly"/>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<select name="status" onchange="showTime(this)">
<option value="New">New</option>
<option value="Pending">Pending</option>
<option value="Complete">Complete</option>
</select>
脚本:
<script language="javascript">
function showTime(obj){
if(obj.value=="Complete"){
//这里直接用new Date()的话显示的会比较难看,可以转化一下
//document.getElementById("completeddate").value=new Date();
var date = new Date();
var newDate = date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
document.getElementById("completeddate").value = newDate
}
}
</script>
<option value="New">New</option>
<option value="Pending">Pending</option>
<option value="Complete">Complete</option>
</select>
脚本:
<script language="javascript">
function showTime(obj){
if(obj.value=="Complete"){
//这里直接用new Date()的话显示的会比较难看,可以转化一下
//document.getElementById("completeddate").value=new Date();
var date = new Date();
var newDate = date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
document.getElementById("completeddate").value = newDate
}
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询