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");

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??

6 Years
Discussion Span
Last Post by sid78669

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'];
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.