表单提交

  1. 表单提交方式
  • 使用submit提交
<form>
  .....
  <input type="submit"/>
</form>
  • 使用button提交表单
<form id = "form1">
  <input type = "text" name = "username"/>
  <br/>
  <input type = "button: value= "提交" onclick="form():"/>
</form>
</body>

<script type= "text/javascript">
  function form1(){
  //获取form
  var form1 = document.getElememtById("form1");
  //设置action
  form1.action = "hello.html";
  //提交form表单  
  form1.submit();
}
</script>
  • 使用超链接提交
<a href="hello.html?username="123456">使用超链接提交</a>
  • onclick:鼠标点击事件
    onchange:改变内容(一般和select一起使用)

  • onfocus:得到焦点
    onblur:失去焦点

<input type="text" id= "id1" name="text1" value="please input" onfocus="focus1();" onblur="blur1();"/>
<script type = "text/javascript">
function focus1(){
var input1 = document.getElementById("id1");
input1.value= "";
}function blur1(){
var input1 = document.getElementById("id1");
input1.value= "please input";
}
</script>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容