Mike
Many thanks, just what I was looking for.
David
"Michael Winter" <> wrote in message
news

pshvbhvrnx13kvk@atlantis...
> On Mon, 22 Nov 2004 13:38:45 +0100, Berislav Lopac
> <> wrote:
>
> > David Groom wrote:
>
> [snip]
>
> >> function SetAnswer(quest,ans) {
> >> var quest,ans;
>
> Delete that statement. The arguments, quest and ans, are already local
> variables.
>
> >> document.diagform.answer[quest].value=quest+'.'+ans;
>
> So you append the answer after the identifier of the question?
>
> >> }
> >>
> >> This works as I expect it, that is to say that when SetAnswer is called
> >> as SetAnswer(q1,1)
>
> I assume you mean
>
> SetAnswer('q1', '1') or SetAnswer('q1', 1)
>
> [snip]
>
> >> [...] I have to change the input names to "answer[]".
>
> [snip]
>
> >> Anyone got any ideas?
> >
> > Instead of form.answer[] (which wouldn't work, use form['answer[]'].
>
> formObj.elements['answer[]']
>
> would be better, however, you can reference the controls directly via
> their id:
>
> function setAnswer(q, a) {
> document.forms['diagform'].elements[q].value = q + '.' + a;
> }
>
> Mike
>
> --
> Michael Winter
> Replace ".invalid" with ".uk" to reply by e-mail.