Jump to content

Is there an easy way to do this?


tcorbeil

Recommended Posts

I don't even know where this question classifies itself but hopefully someone can point me in the right direction:

 

If i have a list as such:

 

-NHL

-MLB

-NBA

-NFL

 

Is there a way to have an option like an 'onclick' where each item that is clicked gives a variable such as $clickedvalue the value of the item clicked while at the same time, routing to a function in separate php file?

 

1) So let's say i clicked on MLB

2) the variable $clickedvalue = item clicked (in this case MLB)

3) call a function in a separate php file for processing..

4) return to main script.

 

so far i know of the href=# but with it, i can't really give my variable a value.. 

 

Maybe i'm asking much so i do appreciate any ideas.

 

Thanks.

T

 

 

Link to comment
https://forums.phpfreaks.com/topic/46802-is-there-an-easy-way-to-do-this/
Share on other sites

Guest prozente

if you are wanting to pass a value to a PHP script based on what link is clicked you can use the GET method.

 

example:

<a href="script.php?myvariable=MLB">MLB</a>
<a href="script.php?myvariable=NBA">NBA</a>

then in script.php

 

you would access the variable by using $_GET['myvariable']

Guest prozente

If you don't want the link to be visible then this defeats the point of the link. If this is the case then don't output the link. If you insist on having the link created but just not visible then you can use CSS.

 

<a style="display:none" href="script.php?foo=bar">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.