Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts

Thursday, December 31, 2015

How to convert string to variable name in Javascript

If you need to create a variable dynamically on the server side and retrieve the value on the client side, use the next example to use the value assigned:

// Declare the variable name
var myStringName = "echoHello";

// Assign a value to the dynamic string variable
window[myStringName] = "Hello from dynamic string variable!";

// Show value
alert(window[myStringName]);

// Or call the variable name
alert(echoHello);


You can even assign a function to the dynamic string variable:

// Declare the variable name
var myStringName = "alertStringVariable";

// Assign a function to the dynamic variable
window[myStringName] = function () {
    alert("Hello from dynamic function variable...");
}

// Execute the function assigned of the variable
alertStringVariable();

Thursday, September 17, 2015

Uncaught TypeError: $(...).datepicker is not a function

If you get the errior:

          Uncaught TypeError: $(...).datepicker is not a function

The most common reason is a duplicate reference to a JQuery file:

  • Verify you don't have different versions of JQuery in the same page
  • If developing MVC, check your BundleConfig and the web page



Wednesday, June 18, 2014

JQuery - Detect a button click

The following example shows how to detect a button click.
With JQuery detect when the document is ready
Load for the button by it's id
Call the Click event of the button
Make an empty function with the code to be executed when the click event happens
 

// Java Script Function
$(document).ready(function () {
    $('#btn').click(function () {
        alert("The button was clicked.");
    });
});


    Click this button:

    

Wednesday, September 18, 2013

JQuery - Get the value of a drop down list


Use this code if you need to get the value of a selected drop down list:

//
// Include a reference to the Jquery library





JQuery Change the form's action url


To change the action form url use the next code:


     



Wednesday, May 8, 2013

JQuery - Get the value of a text box with JQuery


Use this if you need to extract the value of a text box

//
// Include a reference to the Jquery library



JQuery - How to veify JQuery was loadded on the web page



Use this code to verify JQuery was loadded property to your web page.
 

//
// See if the jQuery was loadded
if (jQuery) {  
    alert("jQuery is loaded");
} 
else {
    alert("jQuery is not loaded");
}
//
//

Friday, March 15, 2013

JQuery - Get the value of a radio button


    
    


     A
     B
     C

JQuery - Hide a group of elements

Use the following example to hide a group of elements when a check box is click it using JQuery.

    

        Tmp ones

        



Please hide me!!!!

Friday, February 24, 2012

JQuery check all checkboxes

This is the easiest way to check and uncheck checkboxes in a form.
   
//
// Include a reference to the Jquery library