• Resolved jessezy

    (@jessezy)


    Hi,

    I would like to disable the checkbox until the radio button is selected. I add in some additional JQuery to the form. It is working at the normal HTML page but not working in the contact form.

    May I know what should I do?

    Here is the new code I add in :

    <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script&gt;
    <script>
    $(function() {
    $(“#check_addon input”).attr(“disabled”, true);
    });

    $(function(){
    $(‘input[type=”radio”]’).click(function(){
    if ($(this).is(‘:checked’))
    {
    $(function() {
    $(“#check_addon input”).attr(“disabled”, false);
    });
    }
    });
    });

    </script>

    Thank you

    Regards,
    Jess

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi, you can try below code.

    (function($) {
        //my $ object is local now
       $(“#check_addon input”).attr(“disabled”, true);
       
       $(‘input[type=”radio”]’).click(function(){
    	if ($(this).is(‘:checked’))
    	{
    		$(“#check_addon input”).attr(“disabled”, false);
    	}
      });
    
    })(jQuery);
    Thread Starter jessezy

    (@jessezy)

    Hi,

    Tested. It’s only working while it’s in HTML. Once I added in the wordpress page. It’s not working anymore.

    Thread Starter jessezy

    (@jessezy)

    Hi,

    I found that the script can’t add in the contact form 7, need to add in at the page.

    Thank you for your help. ??

    • This reply was modified 7 years, 8 months ago by jessezy.
    Thread Starter jessezy

    (@jessezy)

    Hi All,

    sorry that another problem. If I add in this jquery :

    <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script>

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    The form is working. But my slider not working. If I remove this JQuery, the form is not working. ??

    what should I do?

    • This reply was modified 7 years, 8 months ago by bdbrown.

    Hi @jessezy

    I have your solution. Do this exactly, very carefully:

    First, create a “.js” fille inside a folder called “js” inside your child-theme (important to have a child theme so it won’t brake or be lost in the next update).

    Let’s say: “scriptNameHere.js”

    Forget jquery.min file… it’s already loaded by your theme, almost certain.

    Your code isn’t properly done. First, … identation for good sake!

    Then, You’ll need to use something like this:

    jQuery(document).ready(function($) {
    
        // vars here
    
        // your functions here 
    
    }

    in that “scriptNameHere.js” file

    Finally you’ll need to call the “js” file in your childtheme’s functions.php using an action:

    function add_custom_script() {
        wp_enqueue_script( 'scriptNameHere', get_stylesheet_directory_uri() . '/js/scriptNameHere.js', array ( 'jquery' ), 1.0, true);
    }
    add_action( 'wp_enqueue_scripts', 'add_custom_script' );

    Voilà!!

    Hope that helps.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘jquery not working’ is closed to new replies.