19

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
  • 7,242
  • 3
  • 57
  • 62
jon de goof
  • 221
  • 1
  • 2
  • 3

4 Answers4

44

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,444
  • 1
  • 16
  • 28
xdazz
  • 154,648
  • 35
  • 237
  • 264
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,037
  • 8
  • 52
  • 66
2
<input type="button" value="..." onClick="fbLikeDump(); WriteCookie();" />
rfunduk
  • 29,455
  • 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,254
  • 1
  • 20
  • 19