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

    Question is there a javascript equivalent to $$var_name in PHP?

    Hello everyone--

    I have been trying to solve a validation problem and I think the only way that i will be able to get it to work is to use the $$var_name [in PHP].

    I have to put some variables together to form the name of the form field names. So the name of an input would be: description_VAR1 and I need to be able to reference the form element named "description_VAR1" to do some string validations. I hope that makes some sense.

    Anyone have any ideas?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Do you mean this?

    var var1 = "blah";
    alert(document.theForm.elements["description_"+var1].value);

    I've been posting this link about "bracket notation" several times in this forum.
    I'll probably put it in my sig later.


  •  

    Posting Permissions

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