Get Row ID as default for form data
Get Row ID as default for form data
davidjmorin
Posts: 101Questions: 31Answers: 0
I currently have a page setup to enter notes about a transaction. This is 2 tables. A note table and an invoice table. The note table has 3 columns. ID, inv_id, note.
How can I get the form to auto-populate the row ID in the form to submit to the note table?
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor({
ajax: 'php/table.id.php',
table: '#idRequest',
fields: [
{
"label": "Notes:",
"name": "daily_notes.note",
"type": "textarea",
},
{
"label": "Note ID:",
"name": "daily_notes.note_id",
"type": "readonly",
"def": "disc_rq_activations.ID", <----- I know this doesnt work.
},
]
});
This discussion has been closed.
Answers
oh forgot to add that I have this as well.
Not inserting note_id into db
You wouldn’t create the ID on the client-side - have the server-side do it (make it an auto incrementing primary key in the database).
Allan
The ID is already in the DB for the Note_ID. It would be row[0] in this example.
I don't quite get it I'm afraid. You have both
ID
andnote_id
. You said in your initial post:Were you actually referring to the
note_id
for the field that you want to auto populate? If so, where are you getting the value from that you want to populate it with?Allan
The note_id is the ID of the row. I have a leftjoin. The join is notes table and the main table is the item table. So the item ID lets say is 20 then note_id when inserted should be 20. If that makes sense lol.
A bit... . So where is the item id coming from? Do you have that in a variable somewhere?
Allan
So the ID is coming from the row that is pulled. It is included in the variable for disc_rq_activations.ID
So basically what Id like is when a note is input that it inserts the ID into the note_id field. This is how I reference it and join them in the table.
Sorry, I'm still a bit confused here. You've got a row, where you want to get the note_id from, but you also want to insert a row, referencing it? Are you using a child table here or something?
Can you give me a link to the page you are working on please, or perhaps just show me the full Javascript? I'm missing how this should all link together.
Allan