Change the selected value of a drop-down list with jQuery

jQuery’s documentation states: [jQuery.val] checks, or selects, all the radio buttons, checkboxes, and select options that match the set of values. This behavior is in jQuery versions 1.2 and above. You most likely want this: $(“._statusDDL”).val(‘2’); Add .change() to see the option in the dropdown list frontend: $(“._statusDDL”).val(‘2’).change();

How to open a Bootstrap modal window using jQuery?

Bootstrap has a few functions that can be called manually on modals: $(‘#myModal’).modal(‘toggle’); $(‘#myModal’).modal(‘show’); $(‘#myModal’).modal(‘hide’); You can see more here: Bootstrap modal component Specifically the methods section. So you would need to change: $(‘#my-modal’).modal({ show: ‘false’ }); to: $(‘#myModal’).modal(‘show’); If you’re looking to make a custom popup of your own, here’s a suggested video from … Read more

Prevent users from submitting a form by hitting Enter

You can use a method such as $(document).ready(function() { $(window).keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); return false; } }); }); In reading the comments on the original post, to make it more usable and allow people to press Enter if they have completed all the fields: function validationFunction() { $(‘input’).each(function() { … } if(good) { … Read more

jQuery disable/enable submit button

The problem is that the change event fires only when focus is moved away from the input (e.g. someone clicks off the input or tabs out of it). Try using keyup instead: $(document).ready(function() { $(‘:input[type=”submit”]’).prop(‘disabled’, true); $(‘input[type=”text”]’).keyup(function() { if($(this).val() != ”) { $(‘:input[type=”submit”]’).prop(‘disabled’, false); } }); });

jQuery get value of select onChange

Try this- $(‘select’).on(‘change’, function() { alert( this.value ); }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <select> <option value=”1″>One</option> <option value=”2″>Two</option> </select> You can also reference with onchange event- function getval(sel) { alert(sel.value); } <select onchange=”getval(this);”> <option value=”1″>One</option> <option value=”2″>Two</option> </select>

How to allow only numeric (0-9) in HTML inputbox using jQuery?

Note: This is an updated answer. Comments below refer to an old version which messed around with keycodes. jQuery Try it yourself on JSFiddle. There is no native jQuery implementation for this, but you can filter the input values of a text <input> with the following inputFilter plugin (supports Copy+Paste, Drag+Drop, keyboard shortcuts, context menu … Read more

How can I get the data-id attribute?

To get the contents of the attribute data-id (like in <a data-id=”123″>link</a>) you have to use $(this).attr(“data-id”) // will return the string “123” or .data() (if you use newer jQuery >= 1.4.3) $(this).data(“id”) // will return the number 123 and the part after data- must be lowercase, e.g. data-idNum will not work, but data-idnum will.

Best way to use Google’s hosted jQuery, but fall back to my hosted library on Google fail

You can achieve it like this: <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js”></script> <script> window.jQuery || document.write(‘<script src=”/path/to/your/jquery”><\/script>’); </script> This should be in your page’s <head> and any jQuery ready event handlers should be in the <body> to avoid errors (although it’s not fool-proof!). One more reason to not use Google-hosted jQuery is that in some countries, Google’s domain name … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)