What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How to reset a radio button using custom Javascript code? RESOLVED

    Asked by AA_C on January 26, 2016 at 04:19 PM

    I am trying to reset these radio button fields

    input_76_1006" name="q76_membershipType76[][id]" value="1006" />

    input_76_1007" name="q76_membershipType76[][id]" value="1007" />

    I have this script:

         function fieldReset()     {

            var ind = document.getElementById("input_76_1006").value= '';

            var fam = document.getElementById("input_76_1007").value= '';       

        }

    and this button

    fieldReset()" value="Reset Selection" />

     

    Why won't it work?

     

     

     

    The form url below dose not have the script, it is the form where I want to put the script.

     

    Robert

    Page URL:
    https://www.aac.ca/en/membership/main/form_en.aspx

    JotForm checkbox style uploads name
  • Profile Image
    JotForm Support

    Answered by Kevin_G on January 26, 2016 at 07:11 PM

    I checked your Javascript code and it's not working on my end, however, I change your function and used this one: 

    function fieldReset(){

           var ele = document.getElementsByName("q76_membershipType76[][id]");

      for(var i=0;i<ele.length;i++)

         ele[i].checked = false;

       }

    It should reset the selections, I tried it and worked on my end, replace the name highlighted on the Javascript function with the name of your radio buttons, highlighted on the HTML code below.

    Here is the HTML code:

    <input class="form-checkbox validate[required]" type="radio" id="input_76_1006" name="q76_membershipType76[][id]" value="1006" />

     

    <input class="form-checkbox validate[required]" type="radio" id="input_76_1007" name="q76_membershipType76[][id]" value="1007" />

     

    <input type="button" onclick="fieldReset()" value="Reset Selection" />

    Test it and let us know how it works.

  • Profile Image

    Answered by AA_C on January 26, 2016 at 09:04 PM

    Thank you works perfectly...

    Robert

  • Profile Image

    Answered by AA_C on January 26, 2016 at 10:00 PM

    I just noticed although the radio button is reset the total remains until another selection is made. How can we reset the total to 0 at the same time?

  • Profile Image
    JotForm Support

    Answered by ashwin_d on January 27, 2016 at 03:21 AM

    Hello AA_C,

    Please use the following function and see if that solves your problem:

    function fieldReset(){

           var ele = document.getElementsByName("q76_membershipType76[][id]");

      for(var i=0;i<ele.length;i++)

         ele[i].checked = false;

         document.getElementById('payment_total').innerHTML='0.00';

       }

    Do test it and get back to us if you have any trouble. You may also like to share the webpage URL where you have implemented the above script as it will help us test the issue.

    Thank you!

  • Profile Image

    Answered by AA_C on January 27, 2016 at 09:37 AM

    YOU GUYS ARE GREAT... I Will have to hone up my JS skills.

    I tried this and it didn't work;

    document.getElementById('payment_total').value= ''0";

    If I may pick your brains, why didn't mine work and

    what is the function of .innerHTML 

     

    Thanks Very Much, Problem Solved

    Robert

  • Profile Image
    JotForm Support

    Answered by ashwin_d on January 27, 2016 at 11:49 AM

    Hello Robert,

    ".innerHTML" is used to set the value of span, div or <td> etc elements other than the form input elements. 

    Since the "payment_tool" is actually span in the form, that is the reason why it did not work for you. I am glad to know that your issue is now resolved. 

    Do get back to us if you have any questions.

    Thank you!