选择<选择>来自具有相同名称的多个标签选择>
if (fromObject == null) fromObject = primaryTable;
var id = fromObject+"_"+toObject;
var tr = $('<tr id="'+id+'"></tr>').appendTo($("#joins"));
tr.append('<td width=20%><select style="width:100%" type="text" name="from_object" id="from_object" value=""></select></td>');
tr.append('<td width=20%><select style="width:100%" type="text" name="to_object" id="to_object" value=""></select></td>');
tr.append('<td width=20%><input style="width:100%" type="text" name="from_column" id="from_column" value="" readonly></td>');
tr.append('<td width=20%><input style="width:100%" type="text" name="to_column" id="to_column" value="" readonly></td>');
tr.append('<td width=20%><select style="width:100%" type="text" name="join_type" id="join_type" value=""></select></td>');
var combo3 = $("select[name=from_object]");
这是我的问题。我经历了多次附加的过程,并留下了许多具有相同名称的选择标签。我想知道如何选择“from_object”。我必须动态地执行此操作吗?现在,combo3 始终选择第一个标签。
if (fromObject == null) fromObject = primaryTable;
var id = fromObject+"_"+toObject;
var tr = $('<tr id="'+id+'"></tr>').appendTo($("#joins"));
tr.append('<td width=20%><select style="width:100%" type="text" name="from_object" id="from_object" value=""></select></td>');
tr.append('<td width=20%><select style="width:100%" type="text" name="to_object" id="to_object" value=""></select></td>');
tr.append('<td width=20%><input style="width:100%" type="text" name="from_column" id="from_column" value="" readonly></td>');
tr.append('<td width=20%><input style="width:100%" type="text" name="to_column" id="to_column" value="" readonly></td>');
tr.append('<td width=20%><select style="width:100%" type="text" name="join_type" id="join_type" value=""></select></td>');
var combo3 = $("select[name=from_object]");
Here is my issue. I go through this process of appending multiple times and am left with many select tags with the same name. I would like to figure out how to select the 'from_object'. Do I have to do this dynamically? Right now combo3 always selects the first tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全理解这个问题。获得第一次使用
获得所有使用
但是切勿两次使用相同的 ID。
I don't fully understand the question. To obtain the first use
To obtain all use
However never use the same ID twice.
您的 html 对于这些重复的 ID 无效。我试图同时解决您所要求的问题和重复的 ID 问题。即使不能直接开箱即用,它也应该为您提供解决方案的良好开端。
编辑后的答案
旧答案
if (fromObject == null) fromObject = PrimaryTable;
var id = fromObject+"_"+toObject;
var tr = $('').appendTo($("#joins"));
your html is not valid with those duplicate IDs. I tried to solve both what you asked for and the duplicate ID problem at once. it should give you a good start on a solution, if not work straight out of the box.
edited answer
old answer
if (fromObject == null) fromObject = primaryTable;
var id = fromObject+"_"+toObject;
var tr = $('').appendTo($("#joins"));