1

Dear Stackoverflow members,this question might seem very trivial and honestly I search for an answer however although there are similar queries around, none of the solutions delivered seem to work on what I am trying to achieve. I will put forth a generic snippet to understand what I am trying to achieve.

var dd = addday.getDate() + xdays; //addition of days to user input date 

document.getElementById("Days").value= displaydate;//loading date to Days

where displaydate is in the following format:

var displaydate = dd+'/' + mm + '/' + y; //showing date format

and value shown in real time is displayed in the following input (disabled) box:

<label><b>Expiry Date:</b></label><input type="text" name="Days2" id ="Days2" disabled>

All the above is in a form. What I want to achieve thereafter is that when the user presses submit, that value attained and displayed by the getElementById is inserted in a table.

$addquery2="INSERT INTO 3pxdef_tb(defRef,tlpID,RaisedBy,RaisedDate,defDesc,defCAT,expDate,closedBy,closedDate,acID)VALUES('$_POST[def]','$_POST[tlptsel]','$_POST[raisedby]','$_POST[draised]','$_POST[des]','$_POST[catsel]','$_POST[Days]','$_POST[clby]','$_POST[closeddate]','$acindex')";  

Unfortunately this is not working since an undefined index is being returned by the system.

Can I ask your assistance in this matter?

Thanking you so much.

R.Cremona
  • 59
  • 1
  • 7
  • disabled property input field should not post the value to next page. you can remove disabled property and try again – JYoThI Apr 10 '17 at 04:50
  • in your SQL query replace '$_POST[Days]' with '$_POST[Days2]' i think your problem is just a typo – Iyad Khaddour Apr 10 '17 at 05:27

2 Answers2

1

There are two errors or I should say mistakes in your code first Disabled input tags cannot be posted

see this for more information Disabled form inputs do not appear in the request

Second Just like what Luigi D'Amico said

You're Calling "Days" as id in your JS code but in your html code you have "Days2" as an ID and Name. Rename your Days2 into Days. Your php script also uses that one.

Community
  • 1
  • 1
keysl
  • 2,127
  • 1
  • 12
  • 16
0

You say:

document.getElementById("Days").value

But the html tags id is "Days2"

<input type="text" name="Days2" id ="Days2"

Let us know if this was the issue or if it was just a typo

Luigi D'Amico
  • 665
  • 7
  • 11
  • Dear Team Members, the input tag error was known. The issue was I copy and pasted the code and changed the variables at the last minute. However the good news the non posting was all related to a disabled input tag. Thank you guys !!! very much appreciated. – R.Cremona Apr 10 '17 at 19:09
  • happy you sorted :) – Luigi D'Amico Apr 12 '17 at 04:20