Jump to content


Photo

Click Text


  • Please log in to reply
6 replies to this topic

#1 ari_aaron

ari_aaron
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts
  • LocationToronto, Canada

Posted 16 March 2006 - 01:52 AM

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

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 16 March 2006 - 04:16 PM

[!--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) View Post[/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
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 ari_aaron

ari_aaron
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts
  • LocationToronto, Canada

Posted 17 March 2006 - 12:52 AM

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.

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 17 March 2006 - 01:52 PM

[!--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) View Post[/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:
<?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";
?>

that should start out with the output:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Value of $var: none
[/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: blue
[/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!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 ari_aaron

ari_aaron
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts
  • LocationToronto, Canada

Posted 17 March 2006 - 08:40 PM

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?

#6 Spixxx

Spixxx
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 18 March 2006 - 12:11 AM

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:

<input type="hidden" name="something" value="$something">

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.

#7 ari_aaron

ari_aaron
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts
  • LocationToronto, Canada

Posted 19 March 2006 - 02:17 AM

How is the form submited?


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users