Gary said:
Would it be to much of a bother to ask how I can extend that script
one further? Say I wanted to take a second list of words and only
allow the option of inserting one word from that list in front of
the list of words inserted into the textbox using radio buttons ?
Gary
It 's isn't getting any clearer what you are after, but this does as
requested. In the current design, all words have to be unique. I
don't know if that is a problem. and you need to specify the words in
an array at the start of the script, a bit clumsy. But with that, all
that was needed was to add two short "for" loops, the first removing
anything like a radio'ed word, the second adding the currently
selected word. The process could be repeated for other groups of
words.
<script type="text/javascript">
var oneOf=new Array('One','Word','Only');
function listwords(c) {n=c.value;
s=document.f.out.value;
for(i=0;i<oneOf.length;i++) s=s.replace(' '+oneOf
,'');
for(i=0;i<document.f.radio1.length;i++) {
a=document.f.radio1; if(a.checked)s+=' '+a.value;
}
if (c.checked) {
if (s.indexOf(n)<0) s+=' '+n;
} else {
s=document.f.out.value.replace(' '+n,'');
}
document.f.out.value=s;
}
</script>
<form name="f" method="get" onsubmit="return false">
<input type="text" value="" name="out"><br>
<input type="checkbox" name="check1" value="More"
onclick="listwords(this)">More<br>
<input type="checkbox" name="check2" value="Than"
onclick="listwords(this)">Than<br>
<input type="checkbox" name="check3" value="Before"
onclick="listwords(this)">Before<br>
<input type="radio" name="radio1" value="One"
onclick="listwords(this)">One<br>
<input type="radio" name="radio1" value="Word"
onclick="listwords(this)">Word<br>
<input type="radio" name="radio1" value="Only"
onclick="listwords(this)">Only<br>
</form>