variable part of a variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Markus Schdrunz

    variable part of a variable

    Hi,

    i have a site with many textareas which got numbered names (answer1,
    answer2, answer3). beside each textarea is a link, calling the
    javascript-function putText(). i give the number of the textarea with
    the call: p.e. putText(1)

    in the function putText(textare a) i want to change now
    dokument.myform .answerX.value
    the X behind answer should be the number of the textarea, given to the
    function with the call

    sorry, about my english ;-)

    markus

  • Michael Winter

    #2
    Re: variable part of a variable

    On Sat, 17 Jan 2004 18:21:24 +0100, Markus Schdrunz <markusdaa@yaho o.de>
    wrote:
    [color=blue]
    > i have a site with many textareas which got numbered names (answer1,
    > answer2, answer3). beside each textarea is a link, calling the
    > javascript-function putText(). i give the number of the textarea with
    > the call: p.e. putText(1)
    >
    > in the function putText(textare a) i want to change now
    > dokument.myform .answerX.value
    > the X behind answer should be the number of the textarea, given to the
    > function with the call[/color]

    Try:

    function putText( taIndex ) {
    document.forms['form_name'].elements['answer' + taIndex].value
    = 'Whatever should be assigned to the textarea';
    }

    where the argument, taIndex, is number of the textarea (that is, 1 in
    'answer1', etc), and replacing the form name (form_name, above) and new
    value as appropriate.

    Hope that helps,
    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    Working...