473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Changing a variable onclick

Hi all,

How can I in php have a link that reloads the exact same page but
before reloading, changes some variables?

Cheers,

Paulo Matos

Jul 17 '05 #1
5 2932
NC
pmatos wrote:

How can I in php have a link that reloads the exact
same page but before reloading, changes some variables?


echo '<a href="', $_SERVER['PHP_SELF'],
'?foo=1&bar=2">Click here to change variables</a>';

When the script reloads, you can access the values of
foo and bar as $_GET['foo'] and $_GET['bar'], respectively.

Or, you could just save them as session variables...

Cheers,
NC

Jul 17 '05 #2
echo '<a href="', $_SERVER['PHP_SELF'],
'?foo=1&bar=2">Click here to change variables</a>';


Ah, nice... Didn't know keywords sent in the URL would be sent as GET
variables.
:)

Thanks,

Paulo Matos

Jul 17 '05 #3
*** pmatos wrote/escribió (1 Mar 2005 07:38:59 -0800):
How can I in php have a link that reloads the exact same page but
before reloading, changes some variables?


Code to generate a link:

<a href="<?=$_SERVER['PHP_SELF']?>">Self page</a>
Code to change a variable:

$foo=33;

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #4
NC
pmatos wrote:

Ah, nice... Didn't know keywords sent in the URL would be sent
as GET variables.
:)


Of course. That's how the GET method works...

Cheers,
NC

Jul 17 '05 #5

"pmatos" <po**@sat.inesc-id.pt> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi all,

How can I in php have a link that reloads the exact same page but
before reloading, changes some variables?

Cheers,

Paulo Matos


Link to a PHP file that sets the variable, then do a header("HTTP/1.0 204 No
Contents"), so the browser just stays at the current page.
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
2
by: wjbell | last post by:
I have a piece of javascript I need to modify. Right now it changes a stylesheet in the document between style.css and no_indent.css. These are in the head of my document: <link rel=stylesheet...
14
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only....
2
by: Ian F | last post by:
I have some javascript which allows a header, iframe and picture to be changed when the user clicks a next/previous button. In Opera, if you click next enough times to loop back to the start, or...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
16
by: chris | last post by:
im new to javascript but slowly getting better what i want to do is have some text on the screen and when an event happens for example click a button the text would change to what i want. how...
2
by: celtique | last post by:
Hello everybody! I've just registered to this forum and yet got a question. :) I've got some database, that is processed by PHP in a 'while' loop and each element that the loop draws (<li>) gets...
3
by: naurus | last post by:
I have some code that must change the onclick function of a DIV: function navChange(id,auto){ check = fetchById(id + "More").style.display; if(check == "block"){ showLess(id,auto); } ...
6
by: ndeeley | last post by:
HI, How can I change a form variable with onClick? I have a table which shows the results of a ColdFusion query. I need to have a drop down list box showing the other queries that could be...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.