简体   繁体   English

如何将数据从一个html页面动态添加到另一个html页面中的列表

[英]how to dynamically add data from one html page to a list in another

I have a list of string items on a html page, as follows- 我在html页面上有一个字符串项列表,如下所示 -

<h1><b>Subject Groups</b></h1>
        <div id="listContainer">
            <div class="listControl">
            </div>
            <ul id="expList">
                <li>
                    Maths 
                    <ul>
                        <li>
                            John Smith       
                        </li>
                        <li>
                            Jane Smith
                        </li>
                        <li>
                            Elvis Presley
                        </li>
                    </ul>
                </li>
                <li>
                    Science 
                    <ul>
                    <li>
                    Jane Smith
                    </li>
                    <li>
                    Kate Smith
                    </li>
                    </ul>
                </li>
                <li>
                    Literature
                    <ul>
                        <li>
                            Kate Smith
                        </li>
                        <li>
                            Tom Hanks
                        </li>
                    </ul>
                </li>
                <li>
                <a href = "JavaScript:newPopup('new.html');"<b>New Student..</b></a>
                </li>
            </ul>

At the end of the list, there is a link to a pop up form which allows you to input a new student and select via checkboxes what subjects that person is studying- 在列表的末尾,有一个弹出窗体的链接,允许您输入新学生并通过复选框选择该人正在学习的科目 -

<form action="" style= "font-size: 16pt">

<h3> First Name: </h3>

    <div class="input-group">
      <input type="text" class="form-control">

      <h3> Last Name: </h3>

    <div class="input-group">
      <input type="text" class="form-control">


      <h3> Email Address: </h3>

    <div class="input-group">
      <input type="text" size="70" class="form-control">

    </div><!-- /input-group -->

    <h3> Select the subjects that this student will study: </h3>


<input type="checkbox" name="Maths" value="Maths"> &nbsp Maths<br>
<input type="checkbox" name="Science" value="Science"> &nbsp Science<br>
<input type="checkbox" name="Literature" value="Literature"> &nbsp Literature>
<input type="button" class="btn btn-lg btn-primary btn-block" value="Submit" />
</form>

My question is- how would I go about using the onClick event of the submit button to take the first name and last name of a newly created student and add them to the appropriate subject category in my list? 我的问题是 - 如何使用提交按钮的onClick事件获取新创建的学生的名字和姓氏,并将它们添加到我的列表中的相应主题类别? Is that possible without having a database behind it? 没有数据库背后的可能吗?

I think it will be easy to do with jquery...just give each subject an a ID to like eg <li id="Maths"> then when user submits form get the checkbox value and use .append to add to the list eg 我认为使用jquery很容易...只需给每个主题一个ID,例如<li id="Maths">然后当用户提交表单时获取复选框值并使用.append添加到列表中,例如

> $(chekBoxValue).append("<li>"+name+'</li>');

hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将动态生成的列表中的数据从一页传递到另一页 - Pass data from a dynamically generated list from one page to another Html 如何将数据从一页发送到另一页 - Html how send data from one page to another page 如何将数据从一个页面传递到另一个页面html - How to pass data from one page to another page html 如何在html中将数据从一个页面传递到另一个页面? - How to pass data from one page to another page in html? 如何通过请求将数据添加到另一HTML页面的行中来向一个HTML页面的表中添加行(可能使用“提示”和javascript)? - How to add rows to table in one HTML page by asking for data to be added into rows from another HTML page (may be using “prompt” & javascripts)? 如何使用JavaScript将列表组之类的数据从一个HTML页面传递到另一HTML页面? - How can I pass data like list group from one html page to another using JavaScript? 如何使用javascript将数据从一个html页面传输到另一页面 - how to transfer data from one html page to another using javascript 如何将数据从一个html页面传递到另一个? - How to pass data from one html page to another? 从一个 HTML 页面到另一个页面的表单数据 - Form data from one HTML page to another 从一个 HTML 页面到另一个页面的数据传输 - Data transfer from one HTML page to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM