I need your help,
How can I program a user defined dynamic SQL query.
I have 4 text fields on my webpage.
var a = document.getElementById('prefix').value
var b = document.getElementById('firstname').value
var c = document.getElementById('middlename').value
var d = document.getElementById('lastname').value
How can I use javascript to compile and build an SQL statement if the user fills out either one of the textboxes.
For example, prefix, lastname and firstname are filled in:
SELECT * FROM TABLE WHERE PREFIX = a AND LASTNAME = d AND FIRSTNAME = b
For example, firstname and lastname are filled in
SELECT * FROM TABLE WHERE FIRSTNAME = b AND LASTNAME = d
Is there a better process, other than to use a bunch of if statements to check any 4 of the given conditions?
Seems like iterating through a whole wack of if statements is redundant.
Thanks