Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Button passes js var to SQL query to browse filtered data

Post Reply
Ralcala
Posts: 11
Joined: Fri Aug 16, 2013 4:14 pm

Button passes js var to SQL query to browse filtered data

Unread post by Ralcala »

Hi fellas iam a nbpro newbie and right now iam stuck i just can make SQL statement in General Tab queries for some thing like this

SELECT * from mytable WHERE my field = #jsvar#

its for a Menu of buttons and every button browses different queries

alternate ways to make same task welcome any ideas and advises

Thank you and what a state of art software you developed nbpro team really amazing.
admin
Site Admin
Posts: 2824
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Button passes js var to SQL query to browse filtered dat

Unread post by admin »

Ralcala,

I'm not sure what you are asking but unless your field is a number you will need to put quotes around the hash variable in your sql eg.

Code: Select all

SELECT * from mytable WHERE my field = '#jsvar#'
Steven
Ralcala
Posts: 11
Joined: Fri Aug 16, 2013 4:14 pm

Re: Button passes js var to SQL query to browse filtered dat

Unread post by Ralcala »

Thanks Steven for your quick replay

Here is the process
1.- A Menu of 10 buttons every button have a event on click a JavaScript var to store two digit
2.- When the form loads previously modified SQL Statment on General Tab to
SELECT * mytable WHERE myfield = a global var stored with a two digit previously on click event
3.- Browse window shows only data selected.

my question is what is the code for js in the event on click to store two digit on a global variable that where accessible by all nbpro environment.

Thanks again Steven
admin
Site Admin
Posts: 2824
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Button passes js var to SQL query to browse filtered dat

Unread post by admin »

Ralcala,

Use hash variables.

If you have a field on your Form called two_digits, your Browse Form can use this in its SQL eg.

Code: Select all

SELECT * FROM inventory WHERE inv_code = '#two_digits#'
http://wiki.nubuilder.net/index.php/Hash_Variables

Steven
Post Reply