通过JS将POST数据传递给PHP失败

First time I've added something huge, mixing JS, PHP, THREE and lot of other stuff. This is what I've tried.

When somebody clicks on the THREE.js scene onto a human body, selects parts of the human body and javascript then adds this to a from which I want to save the selected things into database using PHP / MySQL.

The THREE.js scene works, I can select / unselect things and the generated dynamic HTML Output works to. For example I get a form generated like this:

<canvas width="1680" height="949"></canvas>
<div id="Description">Will be added to database:</div>
<form id="BodyParts" method="POST" action="index.php?s=cinput">
    <input type="checkbox" id="leg_right" name="leg_right" disabled="" value="leg_right">
    <div id="leg_right_Description">Rechtes Bein</div>
    <input type="checkbox" id="leg_left" name="leg_left" disabled="" value="leg_left">
    <div id="leg_left_Description">Linkes Bein</div>
    <input type="checkbox" id="torso_top" name="torso_top" disabled="" value="torso_top">
    <div id="torso_top_Description">Obertorso</div>
    <input type="submit" value="Speichern" id="Submit">
</form>

So, after clicking onto the submit Button I am just using var_dump($_POST); on my receiving cinput.php file. But it gives out an empty array. However when trying to reload the site Chrome tells me that some data has been sent and I need to verify it again. You know what I mean. How the heck does this generated HTML Form above not work and not send POST data which I can use in PHP?

dsdukbc60905239
dsdukbc60905239 styphon说你应该格式化代码。并非所有人都有10英里宽的显示器,因此他们可以看到您发布的SINGLE代码行。至少花时间正确格式化它,使用换行符,将每个标记放在一个单独的行上,并使用适当的缩进等...
7 年多之前 回复
donglian4770
donglian4770 这不会阻止你进入并格式化它,因此它是可读的......
7 年多之前 回复
droebnxrm31502512
droebnxrm31502512 Styphon:因为没有什么可以发布的。上面的代码是我在JS/THREE.js场景中自动生成的表单,我点击它。它基本上只是提交的form()和使用var_dump($_POST)的接收文件;没有更多的帖子!
7 年多之前 回复
dongqi19827
dongqi19827 发布一些可读代码而不是单行怎么样?
7 年多之前 回复

1个回答

You've got the disabled attribute in all of your input fields. The mere PRESENCE of this attribute, even if its value is empty ("") causes the field to get disabled. Disabled fields do NOT get submitted with the rest of the form. Since your entire form has nothing but disabled inputs, you submit nothing at all.

e.g.

<input type="text" value="foo" disabled="" />
<input type="text" value="bar" disabled="false" />
<input type="text" value="baz" disabled="disabled" />

all three of these inputs are disabled, even though by "human" logic, you'd expect only the last one to actually be disabled.

Your submit button is NOT disabled, but since there's no name attribute, it also doesn't submit anything to the form.

donglianjiang9321
donglianjiang9321 嗯,但是当我现在使用JS来设置input.readonly = true; 我仍然可以更改复选框的值(我可以选择/取消选择)。 为什么?
7 年多之前 回复
dongsui3297
dongsui3297 禁用将它们变成基本的窗口装饰。 它们看起来像输入元素,但不像输入元素那样ACT。 readonly使它们启用,但不可更改。
7 年多之前 回复
dongmeirang4679
dongmeirang4679 咦? 我添加了它们,因为我想在“readonly”上设置这些复选框。 所以你说“残疾人”不像“只读”。 Pfff。 谢谢!
7 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐