SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Why I cannot pass in more than 2 parameters?

    Hi,

    I have a function that accepts three parameters as follows:

    Code:
    function validate(sID,nullable,displayFormat){
    
    var spanID = sID;
    var checkNull = nullable;
    var validateDisplay = displayFormat;
    
    alert(spanID + checkNull);
    
    }
    
    //this function call prompt error
    <input type="text" onchange="validate(firstText,false,date)" >
    
    //this function is ok
    <input type="text" onchange="validate(firstText,false)" >
    The browser's status bar will show 'error' when I am trying to call the validate function with three parameters but it will work if I only pass in two variables.. it will show the message box..

    May I know what did I miss that causes the error for calling the function with three parameters?

    Any comment and help will be greatly appreciated. Thank you.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Because in essence you are not passing three arguments on the fired event.
    the script is asking itself, what is firstText, what is nullable and what is date?

    if you tell the function that the firstText is the value of the text input:
    Code:
    <input type="text" onchange="validate(this.value, false, 'date')" >
    it will work
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Tags for this Thread

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
  •