Jump to content

Archived

This topic is now archived and is closed to further replies.

ari_aaron

Click Text

Recommended Posts

How can I make some text, and when it is clicked, some code is executed?

Share this post


Link to post
Share on other sites
[!--quoteo(post=355545:date=Mar 15 2006, 08:52 PM:name=ari_aaron)--][div class=\'quotetop\']QUOTE(ari_aaron @ Mar 15 2006, 08:52 PM) [snapback]355545[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How can I make some text, and when it is clicked, some code is executed?
[/quote]

welcome to the forums. i hope you are able to find lots of help here.

as to your question, you'll have to be a little more detailed, as there are a LOT of ways to do what you're after, but they all approach the idea differently. you can make the text a link and just check with PHP to see if the link has been followed, or you can use AJAX to do something similar without refreshing the page. another option would be to have a hidden form that is submitted when you click the text.

basically, what i'm getting at is you need to define more specifically what you mean by "some code is executed"... what result are you after? what kind of interface are you wanting to keep, etc...

the more detail you can give, the more likely we'll be able to help you come up with a workable solution

good luck

Share this post


Link to post
Share on other sites
Thank you, I want to have the page run an SQL query and then change a variable. Does refreshing a page clear the POST data that it received? if so, I would not want to do that (although I guess I could pass it on). I would want the new variable to be displayed, though.

Share this post


Link to post
Share on other sites
[!--quoteo(post=355753:date=Mar 16 2006, 07:52 PM:name=ari_aaron)--][div class=\'quotetop\']QUOTE(ari_aaron @ Mar 16 2006, 07:52 PM) [snapback]355753[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thank you, I want to have the page run an SQL query and then change a variable. Does refreshing a page clear the POST data that it received? if so, I would not want to do that (although I guess I could pass it on). I would want the new variable to be displayed, though.
[/quote]

$_POST variables are only received when a page is loaded, so i'm not sure what you mean by "clear" the data. if you're looking to have recurrent pages reference the same variable, you'll want to go with session variables, but let's take this one step at a time. copy and paste this code and see if it gives the basic idea of what you're after:
[code]
<?php
$var = isset($_GET['var']) ? $_GET['var'] : 'none';
echo "Value of \$var: <b>$var</b><br />\n";
echo "<a href='?var=blue'>change to \"blue\"</a>\n";
?>
[/code]

that should start out with the output:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Value of $var: [b]none[/b]
[/quote]

then, when you click on the link, it should refresh as:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Value of $var: [b]blue[/b]
[/quote]

if you understand the principles, you can easily apply a SQL query where you'd like instead of simply assigning the value to the variable manually.

hope this helps!

Share this post


Link to post
Share on other sites
yes, that is what I need, but when it loades the second time, it does not keep the POST data it received from before. How can I pass this on?

Share this post


Link to post
Share on other sites
The answer if you need to have a hidden input. Example:

You have a form, a user submits the data, and is sent to another form within the same php code. You want to use the data from a previous field, or maybe even 2 or 3 forms back. Use this:

[code]
<input type="hidden" name="something" value="$something">
[/code]

Put that in a form to use that data in the next form, and even if you use it then, you need to use that everytime for the following page/form.

I probably made it more complicated that it really is...but you'll get the idea.

Share this post


Link to post
Share on other sites
How is the form submited?


EDIT: Never mind, I'll use session variables.

Share this post


Link to post
Share on other sites

×

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.