Ivo wrote:
> "Gary" <> wrote in message
> news:NmCYb.550116$ts4.306481@pd7tw3no...
>> Ivo wrote:
>>> "Gary" <> wrote in message
>>> news:IVgYb.537154$ts4.42209@pd7tw3no...
>>>> Hello,
>>>> Is it possible to dynamically update a textbox with words chosen
>>>> from a list using form checkboxes and javascript?
>>>> Gary
>>> (...)
>> 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[i],'');
> for(i=0;i<document.f.radio1.length;i++) {
> a=document.f.radio1[i]; 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>
Ivo,
It doesn't look like that will work for me after all, if I haven't worn out
my welcome would it be possible for you to show me how I can "surround" the
list of words created from the checkboxes with "predefined" text selected
with radio buttons? i.e.:
words selected with checkboxes = one, two, three
<text from radio1 here>one, two, three</end text from radio1>
or
<text from radio2 here>one,two,three</end text from radio2>
Thanks in advance
Gary
|