20

Does someone know a wizards trick to make it work ?

<input type="button" value="Dont show this again! " onClick="fbLikeDump();" onclick="WriteCookie();" />

PS: I am using it in a .js file.

Joshua Dance
  • 8,847
  • 4
  • 67
  • 72
jon de goof
  • 231
  • 1
  • 2
  • 3

4 Answers4

46

Additional attributes (in this case, the second onClick) will be ignored. So, instead of onclick calling both fbLikeDump(); and WriteCookie();, it will only call fbLikeDump();. To fix, simply define a single onclick attribute and call both functions within it:

<input type="button" value="Don't show this again! " onclick="fbLikeDump();WriteCookie();" />
Dhruvan Ganesh
  • 1,502
  • 1
  • 18
  • 30
xdazz
  • 158,678
  • 38
  • 247
  • 274
4

Try it:

<input type="button" value="Dont show this again! " onClick="fbLikeDump();WriteCookie();" />

Or also

<script>
function clickEvent(){
    fbLikeDump();
    WriteCookie();
}
</script>
<input type="button" value="Dont show this again! " onClick="clickEvent();" />
Danilo Valente
  • 11,270
  • 8
  • 53
  • 67
2
<input type="button" value="..." onClick="fbLikeDump(); WriteCookie();" />
rfunduk
  • 30,053
  • 5
  • 59
  • 54
2

Give your button an id something like this:


<input id="mybutton" type="button" value="Dont show this again! " />

Then use jquery (to make this unobtrusive) and attach click action like so:


$(document).ready(function (){
    $('#mybutton').click(function (){
       fbLikeDump();
       WriteCookie();
    });
});

(this part should be in your .js file too)

I should have mentioned that you will need the jquery libraries on your page, so right before your closing body tag add these:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://PATHTOYOURJSFILE"></script>

The reason to add just before body closing tag is for performance of perceived page loading times

Mirko
  • 4,284
  • 1
  • 22
  • 19