form表单提交和git远程分支

1、一个html页面中,form表单数据比较分散,有两种常见的情况:
(1)submit按钮不在form表单之中:
这种情况下有两种方法可以实现:

第一种:通过html5实现

<form name="myform" action="1.html" method="post">
     用户名:<input type="text" name="userName" />
</form>
<button onclick="document.myform.submit();">提交表单</button>

第二种:通过Js实现

<form action="index.php" id="form" method="post" name="myform">
    姓名:<input type="text" name="name"><br>
    密码:<input type="password" name="password">
</form>

<button id="submit">提交改变表单</button>
<script>
   $('#submit').click(function(){
           $('form').submit();
   })
</script>

第三种:通过ajax实现
//不做介绍

(2)要提交的表单数据不在form表单中
这种情况下可以考虑在表单内部设置一个隐藏表单,通过js获取表单外面的值,并将其赋给隐藏表单

<form action="index.php" id="form" method="post" name="myform">
    姓名:<input type="text" name="name"><br>
    密码:<input type="password" name="password">
    <input type="hidden" name="hobby" value="" id="hiddenHobby">
    <input type="submit" value="提交" id="submit">
</form>
爱好:<input type="text" name="hobby" id="showHobby">
<script>
    //页面加载后获取form外的表单元素值
    $('#hiddenHobby').val($('#showHobby').val());
    $('#showHobby').blur(function(){
        $('#hiddenHobby').val($(this).val());
    })
</script>

2、git相关:远程分支
在本地拷贝远程分支的代码:

git pull origin 分支名
//例如: git pull origin develop

只拷贝远程仓库中的某一个分支

git clone -b 分支名  git地址
例如: git clone develop git@git.oschina.net:yancun/gitLearn.git
posted @ 2017-08-17 23:48  蚁象  阅读(270)  评论(0编辑  收藏  举报