开发者

Nested Input Elements do not seem to appear in the dom

Im building a wordpress plugin for client that does a number of jobs.

My goal is to simply get all the input 开发者_开发技巧tags in some html and use the data.

I have some html(that contains inputs)

The user fills the inputs in and clicks save.

Javascript puts the entire htmlinto another hidden input for POSTING purposes.

I then retrieve the html from posted item ie: $_POST["my_html"]

I get the input elements using the DOM. getElementsByTagName.

But the input values are EMPTY.

Am I doing something wrong. Can this be done (above) ?


Why choose such a difficult path? Just submit your form normally and get the values from $_POST. As for your method, my guess (since no code is provided) is that you try to add whole DOM element as a string. You need to set each's elements value (element.value) not the whole element. I could clarify my answer if some code could be provided.


The correct way to serialize a form is not to store its' html markup. You should be storing key-value pairs instead, which can be neatly serialized in a number of ways, JSON being a very popular and easily graspable method.

There's also the possibility of submitting your form directly to the handling script, which has been a working solution since HTML 2.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜