SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    functions + arguments

    just out of curiousity is this pos

    PHP Code:

    function robust(arg1arg2)
    {
        for (
    i=0;i<robust.arguments.length;i++)
        {
            
    alert('alert for each arg')
        }

    is it possible to leave the number of arguments underfined so that the user could click a form and every time they use a textbox it counts each argument that is passed.

    so i wouldn't have to define one variable and split that into an array.

    ps i did't realise you could call a function within itself like java can

    so I take it recursion is possible then

    PHP Code:

    function Ftimes() { 
        var 
    FtimesObj = new Object() 
        function 
    Ftimes3(x) { 
            return 

            

        function 
    Ftimes4(x) { 
            return 

            

        
    FtimesObj.Ftimes3 Ftimes3 
        FtimesObj
    .Ftimes4 Ftimes4 
        
    return FtimesObj 
        

    Multi = new Ftimes() 
    alert(Multi.Ftimes3(5)) // alerts 15 
    Last edited by Andrew-J2000; Apr 9, 2002 at 02:12.

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well you could get the collection of
    textareas from the document, either at submit point
    or before and set onblurs:

    var ta=document.getElementsByTagName('TEXTAREA');

    Now you can either loop through onload and set an
    onblur, or loop through on submit.

    I'm guessing you'll want to set an onblur and have it
    add the name of the element to a pre-initialised array for checking onsubmit?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    urm i was just curious if i could make the value null in the function argument. Im not actually making this.

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LMFAO
    ok... i see... sozzie


    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the JavaScript OOP Articles on Sitepoint. It covers these topics:

    function basicFunction(){
    for(i=0;i<arguments.length;i++){
    alert(arguments[i]);
    }
    }

    aDog


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
  •