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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing multipule parameters in a string

    How would I also pass a variable that is a number in the follow example?

    timer = setInterval("myfunction('"+string+"')", 1000)
    Last edited by Graeme Hackston; 02-28-2003 at 01:51 AM.

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    timer = setInterval("myfunction('"+string+", 2')", 1000)
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry John, I edited my question while you were posting but I'll give this a try

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No I should have been more clear the first time. I want to pass 2 variables, ones a string the other a number (which now I'm thinking doesn't matter).

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    timer = setInterval("myfunction('"+string+"',"+number+")", 1000)

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perfect, thanks guys. I'll have to stare at this until it makes sence

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts

    other parameter types

    if you are passing a reference to a form field:

    timer = setInterval("myfunction(document."+obj.form.name+"."+obj.name+")", 1000)

    where obj is the variable that referenced to a form field.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, thanks Glen, I can actually read that one but never would have thought of it. In the 1st example you posted, why are the single quotes only around the first parameter?

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok I think I've got it, it does matter whether it's a string or number

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    yes, you're right.

    if the values of the variable string and number have these values:

    string = 'blah';
    number = 1;

    executing this:

    timer = setInterval("myfunction('"+string+"',"+number+")", 1000)

    would look like:

    timer = setInterval("myfunction('blah',1)", 1000)

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the visual Glen. Now I can see exactly why.


  •  

    Posting Permissions

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