#7Froms

作者: 淇漯草 | 来源:发表于2018-08-08 16:56 被阅读0次

    用途

    搜集用户输入的信息,作为借口
    通过网络发送数据


    form

    属性一
    action:告诉form 内容送到哪里去
    属性二
    method: 告诉form,如何送。
    value有默认get和post(隐藏着送)
    get用于不敏感的信息
    post用于安全的信息

    <form action = "processingscript.php" method = "post"></form>


    input

    无需closing tag
    <input type="text">一个基础的文本输入框

    <input type="password">不给看的文本输入框

    <input type="checkbox" (可选,checked) >方块可点击
    <input type = "radio">圆圈
    这两个都有一个checked 属性,直接放后面


    image.png

    textarea

    多行文本的块,行和列都可以被定义
    rows 和 cols 属性
    <textarea rows="8" cols="20">哈哈哈</textarea>


    image.png

    select

    子标签option
    <select>
    <option>Option 1</option>
    <option>Option 2</option>
    <option value = "third option">Option 3</option>
    <option selected>Rodent</option>(初始选项)
    </select>
    value的值是要被传送过去的信息


    image.png

    Names

    都要加上名字
    因为

    All of the tags mentioned above will look very nice presented on the page but if you hook up your form to a form-handling script, they will all be ignored. This is because the form fields need names. So to all of the fields, the attribute name needs to be added, for example <input type="text" name="talkingsponge">.

        
        <form action="contactus.php" method="post">
    
        <p>Name:</p>
        <p><input type="text" name="name" value="Your name"></p>
    
        <p>Species:</p>
        <p><input name="species"></p>
        <!-- remember: 'type="text"' isn't actually necessary -->
    
        <p>Comments: </p>
        <p><textarea name="comments" rows="5" cols="20">Your comments</textarea></p>
    
        <p>Are you:</p>
        <p><input type="radio" name="areyou" value="male"> Male</p>
        <p><input type="radio" name="areyou" value="female"> Female</p>
        <p><input type="radio" name="areyou" value="hermaphrodite"> An hermaphrodite</p>
        <p><input type="radio" name="areyou" value="asexual"> Asexual</p>
    
        <p><input type="submit"></p>
    
    

    相关文章

      网友评论

          本文标题:#7Froms

          本文链接:https://www.haomeiwen.com/subject/inlxbftx.html