Small javascript question

Discussion in 'Software' started by gamefreak12, Mar 7, 2005.

  1. gamefreak12

    gamefreak12 Private E-2

    I'am using a function:
    <script type="text/javascript">
    function welcome(x)
    {
    document.write(x);
    }
    </script>

    Where it displays a text.

    Now to set what the variable x is, I want to have it on an onclick event like:
    <a href="#" onclick="welcome('Welcome to the site')">Click for welcome 1</a>
    <a href="#" onclick="welcome('Hello!')">Click for welcome 2</a>

    But the onclick codes do not work.

    What should I do to correct this code?
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds