如何用javascript给text赋值 赋什么值?输入框的内容? document.getElementById("a").value = ***; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.getElementById("xxx").value;或document.forms[0].xxx.value; document.getElementById("a").value ==""; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title><script language="javascript">document.getElementById("textfield").value="ssss";</script></head><body><form name="form1" method="post" action=""> <input type="text" name="textfield"></form></body></html>提示:document.getelementbyid 为空或不是对象 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><body><form name="form1" method="post" action=""><input type="text" name="textfield"><script language="javascript">document.getElementById("textfield").value="ssss";</script></form></body></html>再前面html还没生成,当然找不到,或写在onload函数里面 <input type="text" name="textfield" id="textfield"> //加个id <input type="text" name="textfield">document.getElementById是取id所以id不能为空;; 解决.谢谢 mingxuan3000(铭轩)to s_liangchao1s(求学) getElementById可以取到 name="?" 不一定要id 如下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title><script language="javascript">function inita(){document.getElementById("a").value="ssss";}</script></head><body onLoad="inita()"><form name="form1" method="post" action=""> <input type="text" id="a" > </form></body></html>或<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><body ><form name="form1" method="post" action=""> <input type="text" id="a" > <script language="javascript">document.getElementById("a").value="ssss";</script></form></body></html>谢谢大家的关注 document.getElementById是取id所以id不能为空;; 日期格式转换 怎么做日期相减,得出年份 请有资深的大叔们给点意见 js 图片上传预览问题 告诉大家一个很奇怪的js现象。 边距 看看怎么在这只提供试听的网站上下载歌曲.分不够再加 怎样限制file表单控件的浏览类型为某种类型 急...地址栏的阻断字符传不过去怎么办?!100cent mui 的alert弹框确认后 跳转指定页面的问题 望大神指导 求一个正则。关于取第3个逗号前的数据。 使用一段javascript对页面的表格排序,E文和数字类型的没问题,现重金悬赏中文解决方案
或document.forms[0].xxx.value;
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
document.getElementById("textfield").value="ssss";</script>
</head><body>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
</form>
</body>
</html>
提示:document.getelementbyid 为空或不是对象
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title></head><body>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<script language="javascript">
document.getElementById("textfield").value="ssss";</script>
</form>
</body>
</html>
再前面html还没生成,当然找不到,或写在onload函数里面
如下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function inita()
{
document.getElementById("a").value="ssss";
}
</script>
</head><body onLoad="inita()">
<form name="form1" method="post" action="">
<input type="text" id="a" >
</form>
</body>
</html>
或<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title></head><body >
<form name="form1" method="post" action="">
<input type="text" id="a" >
<script language="javascript">
document.getElementById("a").value="ssss";
</script>
</form>
</body>
</html>
谢谢大家的关注