Page 1 of 1

Passing Variables With Onclick...

Posted: Sun Aug 05, 2007 1:02 am
by Grandpa0594
First I want to thank those that helped with a previous question regarding OnClick. Perhaps you can bear with my on another thought I had.

Throughout my page I want to provide the user either buttons or text that will make selections from my database based on the various criteria. As an example, if they click the graphics image "A", it then refreshes the screen and in a section of the screen, all members with names beginning with an "A" appears.

One option is to create 26 pages and use the following OnClick event:

<img border="0" src="images/alphabet/A.jpg" width="24" height="24" vspace="2" onclick=" FP_goToURL(/*href*/'directories/directory%20(a).php')"></td>

Within the called page I would have a Select statement such as:

$query_members="SELECT * FROM Members WHERE BusinessNameKey = 'A' ORDER BY BusinessName";
$query_members="SELECT * FROM Members WHERE BusinessNameKey = 'B' ORDER BY BusinessName";
etc.

Life would be made a whole bunch simpler if I could pass a variable to the called URL. Does anyone know the syntax of such a statement?

My second question is this....

On the primary page, I am also displaying from my database various Business Types. As those business names are drawn from the database I would like to format them with OnClick properties so that when the user clicks them I go to another page, once again passing the text/Business Type selected. The called URL would have a SQL statement such as:

$query_members="SELECT * FROM Members WHERE BusinessType = $businesstype ORDER BY BusinessName";

I am lost as to the syntax of this statement as well.

I would once again like to thank you in advance for any input you could provide...

Posted: Sun Aug 05, 2007 8:18 pm
by califdon
To understand what you're trying to do, I'd need to see your FP_goToURL() function.

You don't need 26 pages and you don't need 26 queries. That's what functions and parameters are for.

Please post your function for us. (And please use the Code tag around your code when you post it.)

Posted: Sun Aug 05, 2007 8:26 pm
by feyd
califdon wrote:Please post your function for us. (And please use the Code tag around your code when you post it.)
Proper (syntax highlighting) tags.

Code: Select all

is to be used as a last resort, not a first.

Posted: Fri Aug 17, 2007 6:14 pm
by califdon
feyd wrote:
califdon wrote:Please post your function for us. (And please use the Code tag around your code when you post it.)
Proper (syntax highlighting) tags.

Code: Select all

is to be used as a last resort, not a first. [/quote]Thanks for the correction, feyd.  I'll try to remember.