A
Anonymous
Guest
I am trying to set the hidden input in the javascript but it doesn't set it in the php.
This is the form with the hidden input. It corresponds to a field in the database table with the name of draggables.
This is where I change the value in the javascript:
The alert pops up with draggable3 as it should but the value of null is what gets saved in the database. The javascript doesn't change the PHP value; it only changes the client side value.
I've also tried getElementsByName but that didn't work either.
This is actually a cakephp site but this problem is with the PHP so I am publishing it here.
This is the form with the hidden input. It corresponds to a field in the database table with the name of draggables.
Code:
<form method="post" accept-charset="utf-8" id="myForm2" action="/mealplans/add">
<input type="hidden" name="draggables" id="drag12"/>
<button id="myId" type="submit">Submit Form</button>
</form>
This is where I change the value in the javascript:
Code:
if(data == "draggable3"){
alert("data " + data);
var x = document.getElementById("drag12").value;
x = "draggable3";
alert(x);
} //end if
The alert pops up with draggable3 as it should but the value of null is what gets saved in the database. The javascript doesn't change the PHP value; it only changes the client side value.
I've also tried getElementsByName but that didn't work either.
Code:
var y = document.getElementsByName("draggables").value; //only changes it on the client
This is actually a cakephp site but this problem is with the PHP so I am publishing it here.