Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007
    Posts
    25
    Plugin Contributions
    0

    Default Javascript validating radio button

    I've done some validation on javascript buttons before, however I can't seem to get on the right track in zen-cart. I think it's because the names of the radio button groups are arrays.

    For instance if my radio buttons looks like this:
    <input name="id[1]" type="radio" value="1" />
    <input name="id[1]" type="radio" value="2" />
    <input name="id[1]" type="radio" value="3" />

    and I'm calling a validation function with:
    if (!validateRadiobutton(document.cart_quantity.id[1])) errs += 1;

    Javascript doesn't seem to like the name being an array
    If I change the html names to:
    <input name="test" type="radio" value="1" />
    <input name="test" type="radio" value="2" />
    <input name="test" type="radio" value="3" />

    and call the function with:
    if (!validateRadiobutton(document.cart_quantity.test)) errs += 1;

    it works just fine.

    Any idea how to properly pass the "id[1]" as the name to javascript?

    Thanks so much for any help!

  2. #2
    Join Date
    Oct 2007
    Posts
    25
    Plugin Contributions
    0

    Default Re: Javascript validating radio button

    pardon my javascript syntax ineptitude.
    For future reference the correct function call would have been

    if (!validateRadiobutton(document.cart_quantity['id[1]'])) errs += 1;
    not
    if (!validateRadiobutton(document.cart_quantity.id[1])) errs += 1;

 

 

Similar Threads

  1. v151 Validating new radio buttons I added to the login page
    By aestheticdesign in forum General Questions
    Replies: 2
    Last Post: 5 Jun 2014, 09:57 PM
  2. GV radio button
    By g_force in forum Managing Customers and Orders
    Replies: 0
    Last Post: 21 Oct 2009, 10:16 PM
  3. Express radio button?
    By amdowney in forum PayPal Website Payments Pro support
    Replies: 2
    Last Post: 25 Sep 2008, 08:23 PM
  4. Replacing option radio button with "Buy Now" button
    By GavCaz in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 31 Aug 2007, 10:17 PM
  5. [Done v1.3.6] javascript not validating
    By s_mack in forum Bug Reports
    Replies: 2
    Last Post: 27 Oct 2006, 10:09 PM

Posting Permissions

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