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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple .value function need help asap

    hi i have got the following function

    it takes 3 strings, what is being copied where it is going and a number which must be placed on the end of what is being copied

    Code:
    function swapvalues(from, num,to){
    var a=from+num;
    to.value=a;
    to.value=a.value';
    }
    what it should do:

    basically add from and num together

    so the inputs will be like this from = "Template" num = "0" ect..

    i want it to add the from and num together to make Template0

    then get the swap the value of the destination with template0

    so to.value=Template0.value

    although this does not seem to work with the a.value thing please help!!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You are creating a string here: var a=from+num;

    that is not an object reference

    You need to do something like

    document.forms[0].elements[from+num].value

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks man, i have fixed the problem now with your help! it had been bugging me for a while


  •  

    Posting Permissions

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