Announcement

Collapse
No announcement yet.

Radio button onchange not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Radio button onchange not working

    I have replaced the <> brackets with () in the script block because of errors when trying to post.

    I would like to execute a function if the 'checked' property of a radio button changes. For testing, I have tried:

    (script type="text/javascript")
    function studentNameFunction() {
    alert('changed');
    }
    (/script)

    <input type="hidden" name="Product_Attributes[5]:code" value="StudentName" data-attribute-type="radio" id="studentName" />
    <input type="radio" name="Product_Attributes[5]:value" value="No" id="l-no" data-attribute="StudentName" checked " />
    <input type="radio" name="Product_Attributes[5]:value" value="Yes" id="l-yes" data-attribute="StudentName" onchange="studentNameFunction()" />

    After the page loads, I change the radio selection from "No" to "Yes" but nothing is happening.
    Last edited by gsam; 03-31-20, 11:24 AM.
    Gary

    [email protected]
    www.icCommerce.com

    #2
    Looks like changing from onchange to oninput solved the problem.
    Gary

    [email protected]
    www.icCommerce.com

    Comment


      #3
      fyi use [ code ] [ / code ] to post code without changing stuff.
      Bruce Golub
      Phosphor Media - "Your Success is our Business"

      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
      phosphormedia.com

      Comment

      Working...
      X