如何获取下拉列表数据 [英] How to fetch dropdown list data
本文介绍了如何获取下拉列表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的jquery代码
i想要获取下拉列表数据
this is my jquery code
i want to fetch the drop down list data
When I Have Click On Add Button IT Add "Undeffind" Value In table row
So what is the Solution for this
script type="text/javascript" src="http://code.jquery.com/jquery.min.js">
$(document).ready(function(){
$(".add-row").click(function()
{
var name = $("#name").val();
var Relation = $("#Relation").val();
var Date=$("#Date").val();
var employed=$("#employed option:selected").val();
var markup = "<tr><td><input type='checkbox' name='record'></td><td>" + name + "</td><td>" + Relation + "</td><td>"+ Date +"</td><td>" + employed +"</td></tr>";
$("table tbody").append(markup);
});
// Find and remove selected table rows
$(".delete-row").click(function(){
$("table tbody").find('input[name="record"]').each(function(){
if($(this).is(":checked")){
$(this).parents("tr").remove();
}
});
});
});
<pre><body>
<form>
<input type="text" id="name" placeholder="Family Member Name">
<input type="text" id="Relation" placeholder="Relation">
<input type="date" id="Date" placeholder="Date of Birth">
<select name="Whether Employed" id="#employed" required>
<option value ="none">Select Here</option>
<option value ="YES" text="Yes" Selected="selected">Yes</option>
<option value ="No" text="No">No</option>
</select>
<input type="button" class="add-row" value="Add Row">
</form>
<table>
<thead>
<tr>
<th>Select</th>
<th>Name</th>
<th>Relation</th>
<th>Date OF Birth</th>
<th>Whether Employed(YES/NO)</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="record"></td>
<td>Peter Parker</td>
<td>peterparker@mail.com</td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
<button type="button" class="delete-row">Delete Row</button>
</body>
</html>
我的尝试:
当我点击添加按钮时在表格行中添加Undeffind值
那么这个
What I have tried:
When I Have Click On Add Button IT Add "Undeffind" Value In table row
So what is the Solution for this
推荐答案
的解决方案是什么(文件).ready(function(){
(document).ready(function(){
(。add-row)。click(function()
{
var name =
(".add-row").click(function() { var name =
(#name)。val();
var Relation =
("#name").val(); var Relation =
这篇关于如何获取下拉列表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文