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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    Location
    Liverpool
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript - form elements and string concatenation

    Totally forgotten how to get round the following problem.

    I am trying to insert a variable(value) into a forms.element command to allow me to check particular element by it's name. Code:-

    var v_name = "aq1";
    if (document.questions.elements[' + v_name + '][0].checked) {

    The above just reads the command as v_name not the content, any help appreciated.

    Thanks

  • #2
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [response deleted to keep liorean from doing anything rash]

    Great link, tho....

    http://www.litotes.demon.co.uk/js_info/sq_brackets.html
    Last edited by cheesebag; 09-30-2003 at 01:21 AM.
     ........ another wild guess ........

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Heh. try changing it from [' + v_name + '] to plain [v_name]
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Ah, cheesebag beat me to it...
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

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