Issues trying to get an element by id

I didn’t get main part of your question. Still let me try: document.getElementById(‘InOrCm’).value = “in”; That mean you are adding value to the input with id “InOrCm”. If I am getting you then your syntax is right. Double check your ‘id’ name. check with console output. document.getElementById(‘InOrCm’).value = “in”; console.log(document.getElementById(‘InOrCm’).value); Here is second part: function … Read more

javascript not loading

Firstly, you don’t need to add scripts in footer.php manually. Secondly, if there are no script dependencies, you have to declare empty array: array(), rather than array(”). Due this mistake scripts are not loading except Bootstrap. The correct code is: function imk_scripts() { wp_enqueue_script( ‘bootstrap_js’, get_template_directory_uri() . ‘/js/bootstrap.min.js’, array(‘jquery’), ‘3.3.5’, true ); wp_enqueue_script( ‘plugin_js’, get_template_directory_uri() … Read more

How to integrate a JS fiddle?

You’re passing true as the $in_footer argument to wp_register_script(), but my_custom_js() is loading in the header. So doubleScroll is loading after the custom js. I would put my_custom_js() in a separate javascript file so you can control the dependencies. Create my_custom_js.js in the same place you have the double scroll script: jQuery(document).ready(function($) { $(“#double-scroll”).doubleScroll(); } … Read more

Disable submit button order

Fixed the issue. Was calling the incorrect IDs. Below is the code I used for anybody else wanting to achieve the same outcome. <script type=”text/javascript” charset=”utf-8″> jQuery(document).ready(function($){ $(“.button#place_order”).click(function () { $(“.button#place_order”).attr(“disabled”, true); $(‘.checkout’).submit(); }); }); </script>

JS file is not loading when i put wp_head() and wp_footer

Something more like this… function wpdocs_theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); // only enqueue jquery if it is not already enqueued! if (!wp_script_is(‘jquery’,’enqueued’)) { wp_enqueue_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js’, array(), true ); } // note: last parameter only needed here if custom.js actually needs jquery wp_enqueue_script( ‘script-name1’, get_stylesheet_directory_uri() . ‘/js/custom.js’, array(‘jquery’) ); // all other scripts clearly … Read more

Custom AJAX form not working async

First probable issue: You’re using name in the form. You should not, since it’s a reserved term in WordPress. Second probable issue: You’re using a form action URL of <?php echo get_template_directory_uri(); ?>/assets/php/process-contact.php. That will break if you use any WordPress functions (or functions defined in functions.php and plugins). This is the correct way to … Read more

Where to paste Google Map Snippet / JavaScript / CSS for WordPress integration

The JS in the fiddle should be saved to a file, for example, scripts.js. If this was in a folder in the theme root called js you could enqueue the scripts like so: function add_wp_scripts() { wp_enqueue_script( ‘google-maps’, ‘https://maps.googleapis.com/maps/api/js’, array(), null, null ); wp_enqueue_script( ‘script’, get_template_directory_uri() . ‘/js/script.js’, array(), null, true ); } add_action( ‘wp_enqueue_scripts’, … Read more

Calling PHP Titles inside Javascript Markup

First, don’t echo your php, but assemble everything in a string, let’s say $titlestring. Next, make this string available for access by the javascript (the slug is the one you used to register the script): $params = array ( ‘titlestring’ => $titlestring, ); wp_localize_script (‘your-script-slug’, ‘IframeTitle’, $params); Finally, access the variable in the script: ‘<div … Read more