Halisco Posted February 16, 2009 Share Posted February 16, 2009 Im trying to use href to call a function. THe application works when i use the link but it is also calling he function when i load the page with a list of these links. How can i fix this? Here is my script: <? echo "<a href=\"" . FunctionOne($ID) . "\">Call Function One</a>"; ?> Quote Link to comment Share on other sites More sharing options...
drisate Posted February 16, 2009 Share Posted February 16, 2009 This is javascript not php bro ... Quote Link to comment Share on other sites More sharing options...
Halisco Posted February 16, 2009 Author Share Posted February 16, 2009 This is javascript not php bro ... Thanks for stating what i am doing wrong but not offering any input as a solution. Quote Link to comment Share on other sites More sharing options...
drisate Posted February 16, 2009 Share Posted February 16, 2009 Thanks for asking your "JavaScript" question in a "JavaScript" forum to have a "JavaScript" awnser ... lol Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted February 16, 2009 Share Posted February 16, 2009 This is javascript not php bro ... Thanks for stating what i am doing wrong but not offering any input as a solution. come on now, let's not get nasty. We are all here volunteering help! Quote Link to comment Share on other sites More sharing options...
Halisco Posted February 16, 2009 Author Share Posted February 16, 2009 This is javascript not php bro ... Thanks for stating what i am doing wrong but not offering any input as a solution. come on now, let's not get nasty. We are all here volunteering help! If he doesnt know how to help me then dont bother posting a reply. And if he does know how to help and does not "volunteer" the info then dont bother replying then either. Ive been googling this for a while with no success and now with frustration with a reply from and A****le like him. So please if you dont have a positive or helpfull reply then don't bother. Forums are about helping not ridiculing people. Quote Link to comment Share on other sites More sharing options...
drisate Posted February 16, 2009 Share Posted February 16, 2009 Bro your aking for help on a javascript question in a PHP board ... What's your problem? I am a PHP developper not a JavaScript freak. I don't care how much big your fraustration is over the prob you have, thats not excusing the fact that you're still not in the good place for help. Here take my hand and let me bring you in the good part of the board ... http://www.phpfreaks.com/forums/index.php/board,6.0.html this guy is incredible Quote Link to comment Share on other sites More sharing options...
Halisco Posted February 16, 2009 Author Share Posted February 16, 2009 Bro your aking for help on a javascript question in a PHP board ... What's your problem? I am a PHP developper not a JavaScript freak. I don't care how much big your fraustration is over the prob you have, thats not excusing the fact that you're still not in the good place for help. Here take my hand and let me bring you in the good part of the board ... http://www.phpfreaks.com/forums/index.php/board,6.0.html this guy is incredible So your telling me there is no way to call a PHP function from within href without using javascript? If that is the case that should have been your original reply. Simply telling someone "thats javascript bro not PHP" is not a clear answer. I think you should learn some Forum etiquette. You may learn this one day when you ask a question about somthing that is not your Forte and someone wastes your time with snarky remarks. If you dont learn any furhter etiquette please do not reply to any of my future posts. It would be much appreciated. PS> thanks for possibly leading me in the right direction.... Quote Link to comment Share on other sites More sharing options...
drisate Posted February 16, 2009 Share Posted February 16, 2009 The way you merged your PHP function into your HTML was so wrong you gave the impression it was a JavaScript function. If you wana load stuff dynamically into a page you should learn AJAX ... that’s basically the "JavaScript" language of PHP ... Quote Link to comment Share on other sites More sharing options...
jackpf Posted February 16, 2009 Share Posted February 16, 2009 Ok ladies, a work around would be this: <?php echo '<a href="'.$_SERVER[php_SELF].'?function=1">Click here to call a function</a>'; if(isset($_GET['function'])) { foo(); } ?> I don't know about calling a function directly on click. You could try echo '<a href="#" onclick="'.foo().'">Function</a> but I don't know if it'll work. Hope that helps. Quote Link to comment Share on other sites More sharing options...
drisate Posted February 16, 2009 Share Posted February 16, 2009 Ok ladies, a work around would be this: <?php echo '<a href="'.$_SERVER[php_SELF].'?function=1">Click here to call a function</a>'; if(isset($_GET['function'])) { foo(); } ?> I don't know about calling a function directly on click. You could try echo '<a href="#" onclick="'.foo().'">Function</a> but I don't know if it'll work. Hope that helps. No that would be a JavaScript syntaxes. PHP is parsed before HTML. When the page is loaded the PHP is static and can't do stuff dynamically unless you use AJAX Quote Link to comment Share on other sites More sharing options...
jackpf Posted February 16, 2009 Share Posted February 16, 2009 No that would be a JavaScript syntaxes. PHP is parsed before HTML. When the page is loaded the PHP is static and can't do stuff dynamically unless you use AJAX You're right actually. Use the GET method instead. Quote Link to comment Share on other sites More sharing options...
Halisco Posted February 17, 2009 Author Share Posted February 17, 2009 No that would be a JavaScript syntaxes. PHP is parsed before HTML. When the page is loaded the PHP is static and can't do stuff dynamically unless you use AJAX You're right actually. Use the GET method instead. Thankyou for your assistance! Quote Link to comment Share on other sites More sharing options...
jackpf Posted February 18, 2009 Share Posted February 18, 2009 No problem. Quote Link to comment 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.