How to create a search box and SQL statement for searching an attribute field?

المشرف العام

Administrator
طاقم الإدارة
How can I add a HTML search bar that the user can use to search an attribute field for a polygon layer, and then tie that input into the SQL statement?

So far I am able to hard code the query of sending a SQL statement and returning a answer using cartodb. My problem is figuring out how to take the input from the search box and automatically inserting the input into the sql statement.

I am using Cartodb api.

var sql = new cartodb.SQL({ user: 'jmann111' }); sql.getBounds("select * from stations where station_nm like ='%" + user_input +"'").done(function(bounds) { map.fitBounds(bounds) });

أكثر...
 
أعلى