I have a javascript code that modifies the data for a hidden field on the page. The page is then submitted to php. The problem is although I can see the altered data in firefox when I select the section and do show source for selection, the modified data in not detected by PHP. Any hints? I'm dumping the post array at the start of the page so I know that I am not getting the data in the PHP to begin with.

Here is the javascript I am using to add the data to the page dynamically:

var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "villageDataNew");
input.setAttribute("value", "987asd9f87s9df87");
document.getElementsByTagName("form")[0].appendChild(input);

On successful execution of JS, I have the following in the page source:

<input value="987asd9f87s9df87" name="villageDataNew" type="hidden"></form>

However, this is only visible when I do show selection source and not when I do show source.

Any idea??

For some apparent reason the whole code started working the second I posted this. For anyone else looking for the solution. The above code works, and you can just look up the data in php by:

echo $_POST['villageDataNew'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.