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
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']

Link to comment
Share on other sites

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">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.