here is the piece of code I want to add the wordpress page:
But when I click visual tab and come back to text tab. The onclick event disappeared:
Can anyone explain why it happens? why do it change the code when I switch the visual and text tab! Thanks in advance!
Check this question:
Wordpress insert javascript into page text area
Basically, check that you are not inside a p or anther element or have a look to the plugin they suggest on that answer:
http://wordpress.org/extend/plugins/raw-html/
Wordpress strips code from your posts which is why that is happening.
Source: http://wordpress.org/support/topic/placing-javascript-in-posts