<script language=javascript>
function getkeyWord(chkId)
{
    var chk = document.getElementById(chkId)
    var word = chk.value;
    
    var oldWords = document.getElementById("txt").value;
    
    if (oldWords.indexOf(word) == -1 && chk.checked)
    {
        document.getElementById("txt").value += " " + word;
    }
    
    if (oldWords.indexOf(word) != -1 && !chk.checked)
    {
        document.getElementById("txt").value = oldWords.replace(" " + word, "");
    }
    
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<input type=checkbox id="chk1" value="a" onclick="getkeyWord(this.id)"/>
<input type=checkbox id="chk2" value="b" onclick="getkeyWord(this.id)" />
<br />
<input type=text name="txt" />
</body>
</html>