ari_aaron Posted March 16, 2006 Share Posted March 16, 2006 How can I make some text, and when it is clicked, some code is executed? Quote Link to comment https://forums.phpfreaks.com/topic/5079-click-text/ Share on other sites More sharing options...
obsidian Posted March 16, 2006 Share Posted March 16, 2006 [!--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 solutiongood luck Quote Link to comment https://forums.phpfreaks.com/topic/5079-click-text/#findComment-18028 Share on other sites More sharing options...
ari_aaron Posted March 17, 2006 Author Share Posted March 17, 2006 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 Link to comment https://forums.phpfreaks.com/topic/5079-click-text/#findComment-18188 Share on other sites More sharing options...
obsidian Posted March 17, 2006 Share Posted March 17, 2006 [!--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! Quote Link to comment https://forums.phpfreaks.com/topic/5079-click-text/#findComment-18337 Share on other sites More sharing options...
ari_aaron Posted March 17, 2006 Author Share Posted March 17, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/5079-click-text/#findComment-18414 Share on other sites More sharing options...
Spixxx Posted March 18, 2006 Share Posted March 18, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/5079-click-text/#findComment-18472 Share on other sites More sharing options...
ari_aaron Posted March 19, 2006 Author Share Posted March 19, 2006 How is the form submited?EDIT: Never mind, I'll use session variables. Quote Link to comment https://forums.phpfreaks.com/topic/5079-click-text/#findComment-18704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.