c_pattle Posted October 9, 2010 Share Posted October 9, 2010 This may not the best place to post this but I'm sure quite a few people here can help. I have an a tag which uses the event trigger "onClick" However when I click on this link the page refreshes. Is there anyway I can stop this? I have copied my code below. <a href=\"#\" class=\"" . $a[$i] . "\" onClick=\"locationValue('" . $a[$i] . "', '" . $_GET['search_type'] . "')\"> Link to comment https://forums.phpfreaks.com/topic/215501-stop-refresh-onclick/ Share on other sites More sharing options...
BlueSkyIS Posted October 9, 2010 Share Posted October 9, 2010 return false. onClick='somefunction1();somefunction2();etc();return false;' Link to comment https://forums.phpfreaks.com/topic/215501-stop-refresh-onclick/#findComment-1120601 Share on other sites More sharing options...
jcbones Posted October 9, 2010 Share Posted October 9, 2010 You are telling it to refresh in your href: change it to: <a href=\"javascript:void(0);\" class=\"" . $a[$i] . "\" onClick=\"locationValue('" . $a[$i] . "', '" . $_GET['search_type'] . "')\"> Link to comment https://forums.phpfreaks.com/topic/215501-stop-refresh-onclick/#findComment-1120604 Share on other sites More sharing options...
c_pattle Posted October 9, 2010 Author Share Posted October 9, 2010 Thank you both for your feedback. Both of the solutions about work, although which one is the best one to use? Link to comment https://forums.phpfreaks.com/topic/215501-stop-refresh-onclick/#findComment-1120613 Share on other sites More sharing options...
BlueSkyIS Posted October 9, 2010 Share Posted October 9, 2010 i believe the second option may be the later, "better" option these days. my option is what I have been doing for years and it may not be the best of the 2 options. I learn here at least as much as I teach. Link to comment https://forums.phpfreaks.com/topic/215501-stop-refresh-onclick/#findComment-1120630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.