appendChild复选框不提交 [英] appendChild checkboxes not submitting

查看:70
本文介绍了appendChild复选框不提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面根据您选择的城市更改复选框列表,但是当我插入新节点时,值不是

时提交的盒子被检查并且表格被发送,就像他们

没有正确地挂在表格上一样。


任何帮助都会被认可

JAVASCRIPT ///

cities [0] =" ne,nw,se,sw" ;;

//更改城市quadrent

function write_quadrent(city_id){

var quadrents = cities [city_id] .split(",");

var newnode = document.createElement(" div");

newnode.id =" advanced_city_quadrent";

for(var i = 0; i< quadrents.length; i ++){

var newnode_input = document.createElement(" INPUT");

newnode_input.type =" checkbox" ;;

newnode_input.name =" quadrent" ;

newnode_input.id =" quadrent";

newnode_input.value = qu adrents [i];

var newnode_text = document.createTextNode(quadrents [i]);

newnode.appendChild(newnode_input);

newnode .appendChild(newnode_text);

}

//创建新节点

var checkboxes = document.getElementById(" advanced_city_quadrent");

var replacement = par.replaceChild(newnode,checkboxes);

}


END JAVASCRIPT ////

< form id =" propertysearch" name =" propertysearch"

action =" /cmn/apps/form_router.php" method =" post">


< div id =" advanced_city_quadrent_holder">

< div id =" advanced_city_quadrent">


< script type =" text / javascript">

write_quadrent(readCookie(''city''));

< / script>

< / div>

< / div>

< input type =" submit" ; value =" submit" />

< / form>

因此,在上面给出的示例中,您可以说Cookie city设置为0,

它通过并为该

城市的每个四分之一写一个复选框,工作正常并且盒子改变但是当我提交它们时

don不发送任何值。

I have a page that changes a list of checkboxes based on what city you
select, however when i insert the new nodes the values are not
submitted when the boxes are checked and form is sent, its like they
are not hooked to the form properly.

Any help would be appritiated
JAVASCRIPT ///
cities[0] = "ne,nw,se,sw";
//change the cities quadrent
function write_quadrent(city_id){
var quadrents = cities[city_id].split(",");
var newnode = document.createElement("div");
newnode.id = "advanced_city_quadrent";
for(var i = 0; i < quadrents.length; i++){
var newnode_input = document.createElement("INPUT");
newnode_input.type = "checkbox";
newnode_input.name = "quadrent";
newnode_input.id = "quadrent";
newnode_input.value = quadrents[i];
var newnode_text = document.createTextNode(quadrents[i]);
newnode.appendChild(newnode_input);
newnode.appendChild(newnode_text);
}
//create new node
var par = document.getElementById("advanced_city_quadrent_ho lder");
var checkboxes = document.getElementById("advanced_city_quadrent");
var replaced = par.replaceChild(newnode,checkboxes);
}

END JAVASCRIPT ////
<form id="propertysearch" name="propertysearch"
action="/cmn/apps/form_router.php" method="post">

<div id="advanced_city_quadrent_holder">
<div id="advanced_city_quadrent">

<script type="text/javascript">
write_quadrent(readCookie(''city''));
</script>
</div>
</div>
<input type="submit" value="submit"/>
</form>
So in the example given above you can say the cookie city is set to 0,
it goes through and writes a checkbox for each quadrent given for that
city, that works fine and the boxes change but when i submit them they
don''t send any values.

推荐答案

在文章< ea ***************** ********@posting.google.com> ,
pa****@Telus.net 启发我们......
In article <ea*************************@posting.google.com> ,
pa****@Telus.net enlightened us with...
我有一个页面根据您选择的城市更改复选框列表,但是当我插入新节点时,在选中复选框并发送表单时,不会提交值,就像它们一样
没有正确地连接到表单。

任何帮助都会被认可
I have a page that changes a list of checkboxes based on what city you
select, however when i insert the new nodes the values are not
submitted when the boxes are checked and form is sent, its like they
are not hooked to the form properly.

Any help would be appritiated




divs不是表格的正确子项。


以下在IE中成功测试过。


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional / / EN"

" http://www.w3.org/TR/REC-html40/loose.dtd">

< html>

< head>

< title>新文档< / title>

< script type =" text / javascript">

var cities = new Array();

cities [0] =" ne,nw,se,sw";


//更改城市quadrent

函数write_quadrent(city_id){

var quadrents = cities [city_id] .split(",");

var f = document.forms [" propertysearch"];

var s = f.elements [" sub"];

for(var i = 0; i< quadrents.length; i ++){

var newnode_input = document.createElement(" INPUT");

newnode_input.setAttribute(" type"," checkbox");

newnode_input.setAttribute(" name",quot; quadrent");

newnode_input.setAttribute(" id"," quadrent");

newnode_input.setAttribute(" value",quadrents [i]);

var newnode_text = document.createTextNode(quadrents [i]);

f.insertBefore(newnode_input,s);

f。 insertBefore(newnode_text,s);

}

//创建新节点

// var par = document.getElementById

(" advanced_city_quadrent_holder");

// var checkboxes = document.getElementById

(" advanced_city_quadrent");

/ / var replacement = par.replaceChild(newnode,checkboxes);

}


< / script>

< / head>


< body>


< form id =" propertysearch" name =" propertysearch"

action ="" method =" get">

< input type =" submit"值= [提交"名称= QUOT;子" id =" sub">

< / form>

< script type =" text / javascript">

write_quadrent(0);

< / script>

< / body>


-

-

~kaeli~

他是你的上帝,他们是你的规则 - 你在地狱里燃烧。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



divs are not proper children of a form.

The following tested successfully in IE.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
var cities = new Array();
cities[0] = "ne,nw,se,sw";

//change the cities quadrent
function write_quadrent(city_id){
var quadrents = cities[city_id].split(",");
var f = document.forms["propertysearch"];
var s = f.elements["sub"];
for(var i = 0; i < quadrents.length; i++){
var newnode_input = document.createElement("INPUT");
newnode_input.setAttribute("type","checkbox");
newnode_input.setAttribute("name","quadrent");
newnode_input.setAttribute("id","quadrent");
newnode_input.setAttribute("value",quadrents[i]);
var newnode_text = document.createTextNode(quadrents[i]);
f.insertBefore(newnode_input,s);
f.insertBefore(newnode_text,s);
}
//create new node
//var par = document.getElementById
("advanced_city_quadrent_holder");
//var checkboxes = document.getElementById
("advanced_city_quadrent");
//var replaced = par.replaceChild(newnode,checkboxes);
}

</script>
</head>

<body>

<form id="propertysearch" name="propertysearch"
action="" method="get">
<input type="submit" value="submit" name="sub" id="sub">
</form>
<script type="text/javascript">
write_quadrent(0);
</script>
</body>

--
--
~kaeli~
He''s your God, they''re your rules - you burn in Hell.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace





kaeli写道:



kaeli wrote:

div不是表格的正确子项。
divs are not proper children of a form.




为什么不,HTML 4的定义是
http://www.w3.org/TR/html4/interact/...html#edef-FORM

并说

< ;!元素表格 - - (%block; | SCRIPT)+ - (FORM) - 交互式表格 - >

其中%block定义为

< !ENTITY%block

" P | %标题; | %列表; | %预格式化; | DL | DIV | NOSCRIPT |

BLOCKQUOTE | FORM |人力资源|表| FIELDSET | ADDRESS">

包含DIV,所以我不明白为什么div不是

表格的正确子女。


请注意,我没有查看原始的海报代码,而是< form>内的< div>

应该不是问题。


-


Martin Honnen
http://JavaScript.FAQTs.com/



Why not, the HTML 4 definition is at
http://www.w3.org/TR/html4/interact/...html#edef-FORM
and says
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
where %block is defined as
<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
which contains DIV so I don''t see why divs are not proper children of a
form.

Note that I haven''t looked at the original posters code but a <div>
inside of a <form> shouldn''t be a problem.

--

Martin Honnen
http://JavaScript.FAQTs.com/


在文章< 40 ******** @ olaf.komtel.net>中, ma ******* @ yahoo.de 开明

我们用...
In article <40********@olaf.komtel.net>, ma*******@yahoo.de enlightened
us with...
kaeli写道:
kaeli wrote:
divs不合适的孩子一个表单。
divs are not proper children of a form.



为什么不,HTML 4的定义是
http://www.w3.org/TR/html4/interact/...html#edef-FORM
并说
<!元素表格 - - (%block; | SCRIPT)+ - (FORM) - 交互式表格 - >
其中%block定义为
< !ENTITY%阻止
P | %标题; | %列表; | %预格式化; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM |人力资源|表| FIELDSET | ADDRESS">
包含DIV,所以我不明白为什么div不是
形式的孩子。

请注意,我没看过原始海报代码,但在< form>内的< div>
不应该是一个问题。



Why not, the HTML 4 definition is at
http://www.w3.org/TR/html4/interact/...html#edef-FORM
and says
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
where %block is defined as
<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
which contains DIV so I don''t see why divs are not proper children of a
form.

Note that I haven''t looked at the original posters code but a <div>
inside of a <form> shouldn''t be a problem.



原始代码附加表格元素到div里面的div,表格里面是

,不是形式本身。

它没有这样的工作方式。当我将它们直接附加到表格

时,它就有用了。我改变了其他一些东西,所以也许是

真的是其他问题。


看看原帖和我的比较有效。你看到

还有什么可能是问题吗?

-

-

~kaeli~

经验是你在获得之后才得到的东西

需要它。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


The original code appended form elements to a div inside a div that was
inside the form, not the form itself.
It didn''t work that way. It worked when I appended them to the form
directly. I changed a couple other things, though, so maybe it was
really something else that was the problem.

Check out the original post and compare to mine that worked. Do you see
what else might have been the problem?
--
--
~kaeli~
Experience is something you don''t get until just after you
need it.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


这篇关于appendChild复选框不提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆