SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member AMC's Avatar
    Join Date
    Jul 2001
    Location
    Sesimbra/Portugal
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Beginner Question

    I'm taking my first steps in vbcode and js so i make lots of stupid mistakes and this must be another one.

    In a form i have a button that when pressed calls a function like this:

    Function1(this.form)

    The funcion header is something like this :

    Function1(theform)

    in the end this function outputs to a text area in the form, like this:

    theform.textarea1.focus()

    Now, i want to use this function with more than one text area, depending on the call so i tried something like this:

    Call:function1(this.form,textareaname)
    Header:function1(theform,thetextarea)
    Output:theform.thetextarea.focus()

    But i get this error: 'thetextarea' is null or not an object.

    Can someone help me with this?

    Thanks.

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If I understand you right....

    ....onClick = "func1(this.form, 'someName')"

    function func1(formObj, fldName)
    {
    formObj.elements[fldName].focus();
    }

    or, if you send the field object itself:

    ....onBlur = "func1(this)"

    function func1(fldObj)
    {
    fldObj.focus();
    }

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Member AMC's Avatar
    Join Date
    Jul 2001
    Location
    Sesimbra/Portugal
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    tks, Vincent, despite my bad explanation you got it perfectly, that was what i was looking for

    By the way do you know some site with good tutorials in this matter ?

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi AMC,

    if you mean good tutorials on syntax -- not really. It tends to be stated and then left for the user to extrapolate. You can skim through the scripts at my site -- I attempt to explain every line I write, but...

    if you mean good javascript tutorials -- my favorite is still www.htmlgoodies.com -- it may be a bit outdated, but it's concise, amusing at times, and simple to understand.

    if you want a good book and you are not a programming novice -- David Flannagan's Javascript: the Definitive Guide (O'Reilly Publishers)

    You might find some of the comments in this thread interesting.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •