[英]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">   Maths<br>
<input type="checkbox" name="Science" value="Science">   Science<br>
<input type="checkbox" name="Literature" value="Literature">   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.