2
<a href="javascript:void(0);" class="selectedpagination"  onclick="changeuploader();">
    Try flash Uploader
</a>

If I write in anchor tag's first parameter javascript:void(0);, it will open link to controller/javascript:void(0)

Also, how do I give it the class name and onclick event?

dbr
  • 165,801
  • 69
  • 278
  • 343
TechCare99
  • 1,763
  • 6
  • 24
  • 33

5 Answers5

8

Easy as that:

anchor('#', 'Try flash Uploader', array('class'=>'selectedpagination', 'onclick'=>'changeuploader();'));

Check this https://www.codeigniter.com/user_guide/helpers/url_helper.html

Stack Programmer
  • 679
  • 6
  • 18
  • what about javascript:void(0) doesn't it need ? – TechCare99 Mar 12 '12 at 13:23
  • use # instead...I've tested and I see that even with it...it will reload the page....I'l make some more tests and report back –  Mar 12 '12 at 13:24
  • `#` will make the browser move the view-port eventually. – hakre Mar 12 '12 at 13:30
  • yeah..it will...to avoid reloading the page, you can add a `return false` to your `onclick` event after your JS function. Maybe it won't work because your JS is returning something, I don't know. About move the view-port, I don't think it will be possible to solve with `anchor()`, if possible, you can create the link manually and it will work the way you need –  Mar 12 '12 at 13:33
  • @Gerep ... Nope. Still using core PHP Code Only. – TechCare99 Mar 13 '12 at 12:15
  • does this link really need to be generated with PHP? –  Mar 13 '12 at 14:59
  • does the `changeuploader` function returns something? –  Mar 14 '12 at 14:29
1

Please stop doing <a href="javascript:void(0);" ... >. It is an extremely bad practice. And so is attaching events in HTML.

Instead you should attach events in an external JS file. PHP framework has nothing to do with this.

tereško
  • 58,060
  • 25
  • 98
  • 150
  • you are right but the thing is that he need to use the framework to create the link and the function for that need a href and TechCare needs it to ignore the click –  Mar 12 '12 at 13:45
  • @tereško may be u r right , but surfing through stackoverflow, I came through this : [link]http://stackoverflow.com/questions/134845/href-for-javascript-links-or-javascriptvoid0 person is having 233 Ups for his answer. ::: More Confused ::: – TechCare99 Mar 12 '12 at 13:45
  • @TechCare99 , did you check to see which answer had bounty awarded ? http://stackoverflow.com/questions/134845/href-for-javascript-links-or-javascriptvoid0/134957#134957 – tereško Mar 12 '12 at 13:48
  • @tereško ... Yes saw that too, thats why I am more confused :| _italic_( I am just a new to JS + jQuery !!! ) – TechCare99 Mar 12 '12 at 13:53
0
  1. onclick="return false();"

    $('.selectedpagination').click(function(){ //To click here });
  2. You can use button.

Ferhat KOÇER
  • 3,890
  • 1
  • 26
  • 26
0

I didn't find another solution instead of: $("a").removeAttr("href");

-1

Try this

<a href="javascript:void(0);" class="selectedpagination"  onclick="javascript:changeuploader();">
    Try flash Uploader
</a>
rash111
  • 1,307
  • 4
  • 19
  • 35