HTML表单方法GET

时间:2014-10-29 12:07:07

标签: html http

我有一个超级简单的html页面,用户输入各种输入,点击提交,并使用HTTP GET表单方法将查询字符串返回到同一页面。

除了前两个文本框或文本区域没有数据外,一切都很好用。我错过了什么,或者它是如何工作的?

以下是代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <h3>User Registration</h3>
    <form action="UserRego.html">
        <p>First Name: 
            <input id="txtFirstName" type="text" />
        </p>
        <p>Surname: 
            <input id="txtSurname" type="text" />
        </p>
        <p>Gender: 
            <input type="radio" name="Gender" value="Male" />Male <input type="radio" name="Gender" value="Female" />Female
        </p>
    <p>Address: 
        <textarea id="taAddress" cols="20" rows="3"></textarea>
        </p>
        <p>Which of the following sports do you like watching?</p>
            <input type="checkbox" name="Sport" value="Soccer" />Soccer<br />
            <input type="checkbox" name="Sport" value="Aussie Rules" />Aussie Rules<br />
            <input type="checkbox" name="Sport" value="Rugby League" />Rugby League<br />
            <input type="checkbox" name="Sport" value="Rugby Union" />Rugby Union<br />
            <input type="checkbox" name="Sport" value="Netball" />Netball<br />
            <input type="checkbox" name="Sport" value="Cricket" />Cricket<br />
        <p>How did you hear about us: 
            <select name="slbRef">
                <option value="Internet" selected="selected">Internet</option>
                <option value="Word of Mouth">Word of Mouth</option>
                <option value="Newspaper">Newspaper</option>
        </select></p>
        <button type="reset">Clear</button>
        <button type="submit">Submit</button>
    </form>
</body>
</html>

1 个答案:

答案 0 :(得分:5)

您忘记添加属性名称=&#34;&#34;对他们来说,

这将有效:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <h3>User Registration</h3>
    <form action="UserRego.html">
        <p>First Name: 
            <input id="txtFirstName" name="txtFirstName" type="text" />
        </p>
        <p>Surname: 
            <input id="txtSurname" name="txtSurname" type="text" />
        </p>
        <p>Gender: 
            <input type="radio" name="Gender" value="Male" />Male <input type="radio" name="Gender" value="Female" />Female
        </p>
    <p>Address: 
        <textarea id="taAddress" name="taAddress" cols="20" rows="3"></textarea>
        </p>
        <p>Which of the following sports do you like watching?</p>
            <input type="checkbox" name="Sport" value="Soccer" />Soccer<br />
            <input type="checkbox" name="Sport" value="Aussie Rules" />Aussie Rules<br />
            <input type="checkbox" name="Sport" value="Rugby League" />Rugby League<br />
            <input type="checkbox" name="Sport" value="Rugby Union" />Rugby Union<br />
            <input type="checkbox" name="Sport" value="Netball" />Netball<br />
            <input type="checkbox" name="Sport" value="Cricket" />Cricket<br />
        <p>How did you hear about us: 
            <select name="slbRef">
                <option value="Internet" selected="selected">Internet</option>
                <option value="Word of Mouth">Word of Mouth</option>
                <option value="Newspaper">Newspaper</option>
        </select></p>
        <button type="reset">Clear</button>
        <button type="submit">Submit</button>
    </form>
</body>
</html>