display calender in click event - javascript

This code is working well in input box.it is not working in a tag
I want to get the same action in a tag 'sample'
I attached my code.
<div id="datepickerContainer">
</div>
<input id="datepicker" type="text">
<script src="/external/jquery.js"></script>
<script src="/jquery-ui.js"></script>
<script>
$( "#datepicker" ).datepicker({
inline: true
});
$('#datepickerContainer').on('click',function() { $( "#datepicker" ).datepicker('show'); });
// Hover states on the static widgets
$( "#dialog-link, #icons li" ).hover(
function() {
$( this ).addClass( "ui-state-hover" );
},
function() {
$( this ).removeClass( "ui-state-hover" );
}
);
</script>

Use below html nd JavaScript code.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="http://www.jscodes.com/codes/calendar_javascript/demo/css/datePicker.css" />
<script src="http://www.jscodes.com/codes/calendar_javascript/demo/js/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="http://www.jscodes.com/codes/calendar_javascript/demo/js/jquery.datePicker-min.js" type="text/javascript"></script>
<title>Content Delv Logs</title>
<script type="text/javascript">
$(window).ready(function() {
$('#date-pick').datePicker({clickInput: true});
});
</script>
</head>
<body>
<input type="text" name="date" id="date-pick" value=""/>
</body>
</html>

Related

Issue in calendar script

I am working on a site your can see the demo here https://masborn.com/theretreatpalmdubai/
The data picker is calendar is not working here.
jQuery(function () {
jQuery("#bookdate").daterange({
showButtonPanel: true,
closeText: "X",
onClose: function () {
jQuery(".bookinginputs").css("display", "block");
},
onSelect: function (){
jQuery("#demodate").css("display", "none");
jQuery(".ui-datepicker-close").css("display", "none");
}
});
});
I have spend many time on it and not find what is the issue here. Can any one give some input?
From the jquery ui documentation, its called "datepicker" not "daterange".
Also, consider using the $ shortcut instead of jQuery, it makes it easier to read.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>

jQuery daterange picker autoclose false not working

i'm using jquery date rangepicker. while i select date from daterange picker i don't want to close the calendar. so i use this code. but it's not working. can any one help. please. here is my code
<div class="form">
<input id="d" class="form__daterange">
</div>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="src/jquery-ui.js"></script>
<script src="src/jquery.daterange.js"></script>
<script>
$(function () {
$("#d").daterange({
numberOfMonths: 12,
minView: 2,
autoclose: false,
});
});
</script>
you need autoClose: false
<script>
$(function () {
$("#d").daterange({
numberOfMonths: 12,
minView: 2,
autoClose: false,
});
});
Try this code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
or modify yours like
<script>
$(function () {
$("#d").datepicker({
});
});
</script>

Calender in inputbox

I want to show datepicker in input box.4 days before This code show datepicker.Now I modified unknownly.I dont know What I changed.Here I attached my code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="http://www.jscodes.com/codes/calendar_javascript/demo/css/datePicker.css" />
<script src="http://www.jscodes.com/codes/calendar_javascript/demo/js/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="http://www.jscodes.com/codes/calendar_javascript/demo/js/jquery.datePicker-min.js" type="text/javascript"></script>
<title>Content Delv Logs</title>
<script type="text/javascript">
$(window).ready(function() {
$('#date-pick').datePicker({clickInput: true});
});
</script>
</head>
<body>
<input type="text" name="date" id="date-pick" value=""/>
</body>
Add this link in your head tag. You are missing jQuery UI library:
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
$(function() {
$( "#datepicker" ).datepicker();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<p>Date: <input type="text" id="datepicker"></p>
use jquery UI with alot of functions and more to give;;;
http://jqueryui.com/
http://jqueryui.com/datepicker/
You just need to enable jQuery UI.
Have a look at this JSFiddle
$(function() {
$( "#datepicker" ).datepicker();
});
Please note how jQueryUI is enabled.

Simple javascript code doesn't work

I am wondering why javascript alerts doesn't popup:
asp.asp file:
<html>
<head>
<meta charset="utf-8">
<title>AAA</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script class="code" language="javascript" type="text/javascript">
$(document).ready(function(){
$( "#btn-statistika" ).click({
alert('ok');
});
$( "#btn-lokality" ).click({
alert('ok');
});
});
</script>
</head>
<body>
<button class='ui-state-default' id='btn-statistika' style='' >Statistika</button>
<button class='ui-state-default' id='btn-lokality' style='' >Lokality</button>
</body>
</html>
Another asp files are working, I don't know why this cannot work...
You need to pass a function as param to click() call
$(document).ready(function () {
$("#btn-statistika").click(function () {
alert('ok');
});
$("#btn-lokality").click(function () {
alert('ok');
});
});
Here is the updated code
<html>
<head>
<meta charset="utf-8">
<title>AAA</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script class="code" language="javascript" type="text/javascript">
$(document).ready(function(){
$( "#btn-statistika" ).click(function(){
alert('ok');
});
$( "#btn-lokality" ).click(function(){
alert('ok');
});
});
</script>
</head>
<body>
<button class='ui-state-default' id='btn-statistika' style='' >Statistika</button>
<button class='ui-state-default' id='btn-lokality' style='' >Lokality</button>
</body>
</html>
Note: You need to pass a function() in click({}); event.

jQuery Attribute Equals selector is not working

jQuery Attribute Equals Selector is not working. Please, have a look into it.
Thanks in advance. :)
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script type="text/javascript" >
$( document ).ready(function() {
alert($( "input[myattr='navo']" ).value);
$( "input[myattr='navo']" ).value="Simon Commission";
alert($( "input[myattr='navo']" ).value);
});
</script>
</head>
<body>
<input type="text" myattr='navo' value="Morley Minto Reform" />
</body>
</html>
Try this,
alert($( "input[myattr='navo']" ).val());
in jQuery value can be get using the method val(), it doesn't have any property like value.
The .value property doesn't exist on a jQuery object. If you want to access the value you have to call the .val() function; if you want to change the value, you have to pass the new value into the .val("some value") function.
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script type="text/javascript" >
$( document ).ready(function() {
alert($( "input[myattr='navo']" ).val());
$( "input[myattr='navo']" ).val("Simon Commission");
alert($( "input[myattr='navo']" ).val());
});
</script>
</head>
<body>
<input type="text" myattr='navo' value="Morley Minto Reform" />
</body>
</html>
$( "input[myattr='navo']" ) returns a jQuery object, not a dom element so it doesn't have a property called value. You need to use the various methods provided by jQuery on the jQuery object.
In this case you can use the .val() method to get/set the value of an input element
$(document).ready(function() {
alert($("input[myattr='navo']").val());
$("input[myattr='navo']").val("Simon Commission");
alert($("input[myattr='navo']").val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="text" myattr='navo' value="Morley Minto Reform" />

Categories

Resources