Passing Variables With Onclick...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Grandpa0594
Forum Newbie
Posts: 2
Joined: Fri Aug 03, 2007 3:40 pm

Passing Variables With Onclick...

Post 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...
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.
Post Reply