【发布时间】:2012-02-12 12:22:34
【问题描述】:
我有以下 HTML:
<form action="/Config.aspx/SDKHome/SaveSections" id="SaveSections" method="post">
<input name="[0].SchemaName" type="hidden" value="contactSection" />
<ul creator="attrCreator" data-dojo-type="dojo.dnd.Source" class="section container dojoDndSource"
style="list-style-type: none;">
<li class="dojoDndItem">
<input name="[0].DefinedAttributes[0].SchemaName" type="hidden" value="firstname" />
</li>
<li class="dojoDndItem">
<input name="[0].DefinedAttributes[1].SchemaName" type="hidden" value="jobtitle" />
</li>
</ul>
</form>
我想将此项目添加到列表中:
<li class="dojoDndItem">
<input name="[X].DefinedAttributes[Y].SchemaName" type="hidden" value="itemToAdd" />
</li>
如何替换 X 和 Y(并通过以下所有项目增加此值),以获得以下 html 作为结果:
<form action="/Config.aspx/SDKHome/SaveSections" id="SaveSections" method="post">
<input name="[0].SchemaName" type="hidden" value="contactSection" />
<ul creator="attrCreator" data-dojo-type="dojo.dnd.Source" class="section container dojoDndSource"
style="list-style-type: none;">
<li class="dojoDndItem">
<input name="[0].DefinedAttributes[0].SchemaName" type="hidden" value="firstname" />
</li>
<li class="dojoDndItem">
<input name="[0].DefinedAttributes[1].SchemaName" type="hidden" value="itemToAdd" />
</li>
<li class="dojoDndItem">
<input name="[0].DefinedAttributes[2].SchemaName" type="hidden" value="jobtitle" />
</li>
</ul>
</form>
【问题讨论】:
-
喜欢这篇文章,但在 for 循环中 stackoverflow.com/questions/1145208/…
-
[]中的数字很重要:(
-
您的数字和值是否有特定的数组?它们有什么关系?
-
它们是从 .NET MVC VIEW 文件动态生成的
-
对不起,我不知道这些文件是如何工作的......
标签: javascript html dojo