Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,497 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,712 people online right now. Registration is fast and FREE... Join Now!




Change $_GET variable onClick

 
Reply to this topicStart new topic

Change $_GET variable onClick

dinci5
4 Mar, 2008 - 12:49 PM
Post #1

New D.I.C Head
*

Joined: 19 Oct, 2006
Posts: 33


My Contributions
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
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Change $_GET Variable OnClick
4 Mar, 2008 - 02:24 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,465



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
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.
User is online!Profile CardPM
+Quote Post

dinci5
RE: Change $_GET Variable OnClick
4 Mar, 2008 - 03:08 PM
Post #3

New D.I.C Head
*

Joined: 19 Oct, 2006
Posts: 33


My Contributions
OK, here is my problem smile.gif



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:

CODE
<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:

CODE
   <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 smile.gif

This post has been edited by dinci5: 4 Mar, 2008 - 03:10 PM
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: Change $_GET Variable OnClick
5 Mar, 2008 - 05:11 AM
Post #4

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

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.
User is offlineProfile CardPM
+Quote Post

dinci5
RE: Change $_GET Variable OnClick
5 Mar, 2008 - 10:14 AM
Post #5

New D.I.C Head
*

Joined: 19 Oct, 2006
Posts: 33


My Contributions
QUOTE(SpaceMan @ 5 Mar, 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.


would you like to share the script with me? smile.gif
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: Change $_GET Variable OnClick
5 Mar, 2008 - 11:30 AM
Post #6

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

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.

This post has been edited by SpaceMan: 5 Mar, 2008 - 11:52 AM
User is offlineProfile CardPM
+Quote Post

dinci5
RE: Change $_GET Variable OnClick
5 Mar, 2008 - 11:43 AM
Post #7

New D.I.C Head
*

Joined: 19 Oct, 2006
Posts: 33


My Contributions
Thanks, I've found it...
I will check it out smile.gif

This post has been edited by dinci5: 5 Mar, 2008 - 11:43 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 08:04PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month