7 Replies - 16885 Views - Last Post: 24 September 2009 - 12:46 AM Rate Topic: -----

#1 dinci5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 19-October 06

Change $_GET variable onClick

Posted 04 March 2008 - 01:49 PM

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
Is This A Good Question/Topic? 0
  • +

Replies To: Change $_GET variable onClick

#2 no2pencil  Icon User is online

  • Head MFIC
  • member icon

Reputation: 5066
  • View blog
  • Posts: 26,449
  • Joined: 10-May 07

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.
Was This Post Helpful? 0
  • +
  • -

#3 dinci5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 19-October 06

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:

<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

Was This Post Helpful? 0
  • +
  • -

#4 SpaceMan  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

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.
Was This Post Helpful? 0
  • +
  • -

#5 dinci5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 19-October 06

Re: Change $_GET variable onClick

Posted 05 March 2008 - 11:14 AM

View PostSpaceMan, on 5 Mar, 2008 - 06:11 AM, said:

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? :)
Was This Post Helpful? 0
  • +
  • -

#6 SpaceMan  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 10
  • View blog
  • Posts: 507
  • Joined: 20-February 03

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.

This post has been edited by SpaceMan: 05 March 2008 - 12:52 PM

Was This Post Helpful? 0
  • +
  • -

#7 dinci5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 19-October 06

Re: Change $_GET variable onClick

Posted 05 March 2008 - 12:43 PM

Thanks, I've found it...
I will check it out :)

This post has been edited by dinci5: 05 March 2008 - 12:43 PM

Was This Post Helpful? 0
  • +
  • -

#8 paomanayo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-September 09

Re: Change $_GET variable onClick

Posted 24 September 2009 - 12:46 AM

View Postdinci5, on 5 Mar, 2008 - 11:43 AM, said:

Thanks, I've found it...
I will check it out :)


I'm after the exact same answer.
Have you had any luck?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1