Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble passing a parameter to a function?

    In the bit of code below, when I try to pass the variable 'field' to the function 'checkIt', in what form must I pass it? I tried "field" and + field + as shown below, but in each case I get javascript errors. If I hardcode field with double quotes around it, I am ok. I know field itself is also ok, because alert(field) shows the expected value.

    function processIt(field) {
    checkIt(+ field +).innerHTML = newText;

    G

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Since field is a variable you passed into the processIt function you should be able to just pass it on without any delimiters, checkIt(field).

    BaldEagle

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    What checkIt() is? a function? This case it woun't work... What in fact are you trying to do? Can you detail and show us the rest of your code?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the response... Well, what I am trying to do is perhaps more simply shown here... I want to pass on the value 0 (ie form=0)to a routine so that searchfrm0 will be operated on, but I get the error message that formnm is undefined...

    var timerID = null;
    var timerOn = false;
    var timecount = 1000;
    function startTime(form) {

    if (timerOn == false) {
    var formnm= 'searchfrm'+form;
    timerID=setTimeout( "hideAll(formnm)" , timecount);
    timerOn = true;
    }
    }
    function hideAll(form) {
    alert(form);
    getObject(form).style.visibility = "hidden";
    timerOn = false;
    }

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And I just figured out that what I need is to define formnm as var formnm before the function declaration... Thanks again!

    G


  •  

    Posting Permissions

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