Skip to content
Advertisement

How can I pass a hidden SQL ID field value alongside other data during a form lookup?

I’m doing my best to put together a basic property management app that will allow users to check out keys to contractors (and check them back in of course). I’m a relatively inexperienced coder and am currently struggling to work out how to pass an additional SQL ID value during a lookup.

The user can currently search for a contractor name and company in the ‘searchcontractor’ input. The backend-search.php file populates this input with FirstName, LastName and Company from the Contractors database, but I cannot work out how to also pass that record’s ContractorID value into a hidden input ‘contractorid’.

Would hugely appreciate any pointers, thank you.

PHP

JavaScript

JavaScript

JavaScript

backend-search.php

JavaScript

Advertisement

Answer

Add the contractor ID as an attribute in the <p> containing the contractor name.

JavaScript

Replace $row["id"] with the actual column name of the contractor ID.

Then copy this to the hidden input field.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement