Hello
Is there a way to change a $_GET variable onclick
so, when link is clicked, the $_GET variable changes...
I searched alot, but didn't find anything
Change $_GET variable onClick
Page 1 of 17 Replies - 15575 Views - Last Post: 24 September 2009 - 12:46 AM
Replies To: Change $_GET variable onClick
#2
Re: Change $_GET variable onClick
Posted 04 March 2008 - 03:24 PM
The answer to your question, in short, is no.
However, with a little more description, there is probably a solution to your request.
To understand why this is not possible (in the manor that you asked) you need to understand how PHP ($_GET) & Javascript (onclick) function as well as how they differ.
When the PHP server receives $_GET variables, they can be parsed, & set to other, familiar named variables. For example $firstname=$_GET['fname'];. Pretty straight forward. This functionality takes place on the web server. Before it is made available to the Clients web browser, something must be done with this variable. For instance, to display the variable one might use echo. echo $firstname. Again, simple enough. However, on the Clients web browser, this will come across only as the value. So if someone used "John" as the input for the variable, then only the text "John" will be displayed in the html. By the time it reaches the Clients web browser, the code for $_GET is lost. So when they click a button with an onclick Javascript function, only the text John is available. & since Javascript can only function on the client side, you loose access to the $_GET variables.
Again, if you post your code & give some description to the problem at hand, I'm sure there is a solution.
However, with a little more description, there is probably a solution to your request.
To understand why this is not possible (in the manor that you asked) you need to understand how PHP ($_GET) & Javascript (onclick) function as well as how they differ.
When the PHP server receives $_GET variables, they can be parsed, & set to other, familiar named variables. For example $firstname=$_GET['fname'];. Pretty straight forward. This functionality takes place on the web server. Before it is made available to the Clients web browser, something must be done with this variable. For instance, to display the variable one might use echo. echo $firstname. Again, simple enough. However, on the Clients web browser, this will come across only as the value. So if someone used "John" as the input for the variable, then only the text "John" will be displayed in the html. By the time it reaches the Clients web browser, the code for $_GET is lost. So when they click a button with an onclick Javascript function, only the text John is available. & since Javascript can only function on the client side, you loose access to the $_GET variables.
Again, if you post your code & give some description to the problem at hand, I'm sure there is a solution.
#3
Re: Change $_GET variable onClick
Posted 04 March 2008 - 04:08 PM
OK, here is my problem 
I'm working with tabs (CSS).
On mouseover, the tab changes, that works fine.
But I want it to remain like when on mouseover when I CLICK on the tab.
I have a Javascript that changes the class of the tab that was clicked on so it looks the same as when on mouseover.
So, it would be logical that the tab that is clicked remains that way.
That works fine when the links are href="#". When I stay on the same page.
Now the problem is, I work with PHP and I include my pages. The links become index.php?p=...
So, the page reloads... That way I loose the class, because It works only when link is clicked.
Here's the java script:
And here are my tabs:
Now I was thinking to keep the '#' in the link and change the $_GET variable onclick...
But when thinking further, that is stupid because the page would be reloaded when a page is included again.
I don't know how to fix this...
maybe change class AFTER link is clicked?
I don't know how to program Javascript.
I found the script above somewhere on the net
I'm working with tabs (CSS).
On mouseover, the tab changes, that works fine.
But I want it to remain like when on mouseover when I CLICK on the tab.
I have a Javascript that changes the class of the tab that was clicked on so it looks the same as when on mouseover.
So, it would be logical that the tab that is clicked remains that way.
That works fine when the links are href="#". When I stay on the same page.
Now the problem is, I work with PHP and I include my pages. The links become index.php?p=...
So, the page reloads... That way I loose the class, because It works only when link is clicked.
Here's the java script:
<script>
function changeClass(obj) {
var ppUl=obj.parentNode.parentNode;
var pLi=obj.parentNode;
var lis=ppUl.getElementsByTagName('LI');
for (var i=0; i<lis.length; i++) {
var lnk=lis[i].getElementsByTagName('A')[0];
if (lnk!=obj) {
lnk.className='';
}
}
obj.className='ITEM_ON';
}
</script>
And here are my tabs:
<ul id="tabsJ"> <li><a href="#" onclick="changeClass(this);"><span>Pocetna</span></a></li> <li><a href="#" onclick="changeClass(this);"><span>Forum</span></a></li> <li><a href="#" onclick="changeClass(this);"><span>Proft Calculator</span></a></li> <li><a href="#" onclick="changeClass(this);"><span>Trade Calculator</span></a></li> </ul>
Now I was thinking to keep the '#' in the link and change the $_GET variable onclick...
But when thinking further, that is stupid because the page would be reloaded when a page is included again.
I don't know how to fix this...
maybe change class AFTER link is clicked?
I don't know how to program Javascript.
I found the script above somewhere on the net
This post has been edited by dinci5: 04 March 2008 - 04:10 PM
#4
Re: Change $_GET variable onClick
Posted 05 March 2008 - 06:11 AM
is a small tabs class script on my site, may give to some clues, or just use it.
it does not have the links, so not page reloads.
it does not have the links, so not page reloads.
#5
Re: Change $_GET variable onClick
Posted 05 March 2008 - 11:14 AM
#6
Re: Change $_GET variable onClick
Posted 05 March 2008 - 12:30 PM
sure, click the link on my signature.
my site not that big, sould be able to find it.
i avoid posting links, so many people think odd things are spam.
dont linke it? call it spam. and it gets removed from the forum.
i actually work for an advertising agency, that people add their email and info to get advertisments about certian topcs.
but low and behold, we get so many people reporting spam to places when they actually subscribed, and the is and unsub link in the email.
is 15 million unsubscribes ATM.
i saw macafee even say they got spam after inputing their email to recive advertisemets?
and they even called it a spam check.
nm, different story.
my site not that big, sould be able to find it.
i avoid posting links, so many people think odd things are spam.
dont linke it? call it spam. and it gets removed from the forum.
i actually work for an advertising agency, that people add their email and info to get advertisments about certian topcs.
but low and behold, we get so many people reporting spam to places when they actually subscribed, and the is and unsub link in the email.
is 15 million unsubscribes ATM.
i saw macafee even say they got spam after inputing their email to recive advertisemets?
and they even called it a spam check.
nm, different story.
This post has been edited by SpaceMan: 05 March 2008 - 12:52 PM
#7
Re: Change $_GET variable onClick
Posted 05 March 2008 - 12:43 PM
Thanks, I've found it...
I will check it out
I will check it out
This post has been edited by dinci5: 05 March 2008 - 12:43 PM
#8
Re: Change $_GET variable onClick
Posted 24 September 2009 - 12:46 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|