Javascript创建的元素未在提交时过帐
我发了几次帖子,但我仍然没有解决这个问题,所以下面是所有代码的示例,问题是动态创建的元素在提交后没有出现在帖子中。但我确实在firefox的修改源代码中看到了它们 Javascript在以下div之间插入元素Javascript创建的元素未在提交时过帐,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我发了几次帖子,但我仍然没有解决这个问题,所以下面是所有代码的示例,问题是动态创建的元素在提交后没有出现在帖子中。但我确实在firefox的修改源代码中看到了它们 Javascript在以下div之间插入元素 <div id="p_scents"> </div> 但如前所述,不在帖子中显示 下面是完整的源代码,以便可以复制该问题 <html >
<div id="p_scents">
</div>
但如前所述,不在帖子中显示
下面是完整的源代码,以便可以复制该问题
<html >
<head>
<script src="/js/jquery.min.js"></script>
<script src="/js/jquery.Jcrop.js"></script>
<script type="text/javascript">
$(function() {
var scntDiv = $('#p_scents');
var i = $('#p_scents p').size() + 1;
$('#addScnt').on('click', function() {
$('<p><label for="p_scnts"><input type="text" size="20" name="url' + i +'" value="" placeholder="Input Value" /></label> <a href="#" id="remScnt">Remove</a></p>').appendTo(scntDiv);
i++;
return false;
});
$('#remScnt').on('click', function() {
if( i > 1 ) {
$(this).parents('p').remove();
i--;
}
return false;
});
});
</script>
<script type="text/javascript">
jQuery(function($){
var jcrop_api;
$('#target').Jcrop({
onChange: showCoords,
onSelect: showCoords,
onRelease: clearCoords
},function(){
jcrop_api = this;
});
$('#coords').on('change','input',function(e){
var x1 = $('#x1').val(),
x2 = $('#x2').val(),
y1 = $('#y1').val(),
y2 = $('#y2').val();
jcrop_api.setSelect([x1,y1,x2,y2]);
});
});
function showCoords(c)
{
$('#x1').val(c.x);
$('#y1').val(c.y);
$('#x2').val(c.x2);
$('#y2').val(c.y2);
$('#w').val(c.w);
$('#h').val(c.h);
};
function clearCoords()
{
$('#coords input').val('');
};
</script>
</head>
<body>
<table border=1 cellpadding="1" cellspacing="0" width=80%>
<form action="/index.php/create" method="post" accept-charset="utf-8"> <tr>
<td>
Select image
</td>
<td>
<input type="file" name="image"/>
</td>
</tr>
<tr><td colspan=2 align=center>
<a href="#" id="addScnt">Add Another Input Box</a>
</td>
</tr>
<tr><td>
Give your banner a unique name</td>
<td>
<input type="text" name="name" value="" id="name" autofocus /> </td></tr>
<tr><td>Specify email address or domain to brand</td>
<td>
<input type="text" name="domainName" value="" id="domain" /> </td></tr>
<tr><td>Status</td>
<td>
<select name="status">
<option value="enabled">Enabled</option>
<option value="disabled">Disabled</option>
</select> </td></tr>
<tr><td>Give you banner a default URL</td>
<td>
<input type="text" name="url" value="" id="url" /> </td></tr>
<tr><td valign=top>Alternate Urls
</td>
<td>
<div id="p_scents">
</div>
<input type=submit>
</form> </td>
</tr>
</table>
</body>
</html>
$(函数(){
var scntDiv=$('p#u scents');
变量i=$('#p#p').size()+1;
$('#addScnt')。在('单击',函数()上){
$('p>')。附录(scntDiv);
i++;
返回false;
});
$('remScnt')。在('click',function()上{
如果(i>1){
$(this.parents('p').remove();
我--;
}
返回false;
});
});
jQuery(函数($){
var jcrop_api;
$('#target').Jcrop({
onChange:showCoords,
onSelect:showCoords,
onRelease:clearCoords
},函数(){
jcrop_api=这个;
});
$('#coords')。关于('change','input',函数(e){
var x1=$('#x1').val(),
x2=$('#x2').val(),
y1=$('#y1').val(),
y2=$('#y2').val();
jcrop_api.setSelect([x1,y1,x2,y2]);
});
});
函数showCoords(c)
{
$('#x1').val(c.x);
$('y1').val(c.y);
$('x2').val(c.x2);
$('y2').val(c.y2);
$('w').val(c.w);
$('h').val(c.h);
};
函数clearCoords()
{
$('coords input').val('');
};
选择图像
给你的横幅一个唯一的名字
指定要注册的电子邮件地址或域
地位
启用
残废
给你一个默认的URL
备用URL
您的HTML中存在多个嵌套错误。您的
标签立即放在
内-这是不正确的!另外,表单
的封闭标签放在最后一个
中。您的标记应如下所示:
<form ...>
<table ...>
<tr ...>
<td ...>
...
</td>
...
</tr>
...
</table>
</form>
...
...
...
您的HTML无效–您不能将表单
作为表
的子元素。谢谢,。如果这能解决我的问题。。我会吻你的脚趾。我会信守诺言;)