Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jquery data picker

Posted on 2011-03-13
9
Medium Priority
?
472 Views
Last Modified: 2012-06-21
dear experts,
I wanted button to display with my date and when the button is clicked the jquery calendar pops up initialized with the date on the button. When the calendar is clicked the button updates with the picked date.

Not sure how to do it. Please help. thanks a lot

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title></title>

  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
 
  <script type="text/javascript" >
      $(document).ready(function() {
          $("#datepicker").datepicker();
      });
  </script>
</head>
<body>
<form runat="server">    
<asp:Button ID="datepicker" runat="server" Text="Button" />


</form>
 
</body>
</html>
0
Comment
Question by:goodk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35122819
I do not know much about asp but it seems that datepicker is designed for input fields of text type. Not sure it this would work, but you could do a hidden text field and update the button with it's value.
0
 

Author Comment

by:goodk
ID: 35122857
can you show in javascript html, how would you code it? I can follow. thanks
0
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 35123165
Hi,

Why are you using a button?

You need to use a textbox instead.

jQuery.datepicker, supports icon trigger, if you need an icon for triggering the date picker:

<script>
	$(function() {
		$( "#datepicker" ).datepicker();
	});
	</script>



<div class="demo">

<p>Date: <input type="text" id="datepicker"></p>

</div><!-- End demo -->

Open in new window


See more details on jquey ui page: http://jqueryui.com/demos/datepicker/#icon-trigger

--------------------------
You can find my on - Development Solutions: www.extremedev.blogspot.com
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:goodk
ID: 35125282
thanks, but I really do not want the date to be editable - only should be able to pick from the calendar. thanks
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 35125488
Hi, use the following example

Page sourcecode

$(function()
{
      $('.date-pick').datePicker({clickInput:true})
});

Page CSS

/* located in demo.css and creates a little calendar icon
 * instead of a text link for "Choose date"
 */
a.dp-choose-date {
      float: left;
      width: 16px;
      height: 16px;
      padding: 0;
      margin: 5px 3px 0;
      display: block;
      text-indent: -2000px;
      overflow: hidden;
      background: url(calendar.png) no-repeat;
}
a.dp-choose-date.dp-disabled {
      background-position: 0 -20px;
      cursor: default;
}
/* makes the input field shorter once the date picker code
 * has run (to allow space for the calendar icon
 */
input.dp-applied {
      width: 140px;
      float: left;
}

more on this

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerClickInput.html
0
 
LVL 9

Accepted Solution

by:
Roman Gherman earned 2000 total points
ID: 35125771
Ok,
Try this then - it works for me:
<html>
<head>
  <script src="http://code.jquery.com/jquery-1.4.4.js"></script> 
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script> 
<script language="JavaScript"> 
$(document).ready(function(){
    $( "#t" ).datepicker();
});
</script>
</head>
 
<body>
	<input type='button' id ='t' value='Show Calendar' onclick='$( "#t" ).datepicker( "show");'/>
</body>
</html>

Open in new window


------------------------
You can find me on: www.extremedev.blogspot.com
0
 

Author Comment

by:goodk
ID: 35130374
wow, works like a charm - but the css look is not same
I created the new css file with code like samirbhogayta: has

<html>
<head>
    <title></title>
   
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
        rel="stylesheet" type="text/css" />
    <link href="../jquery/Calendar.css" rel="stylesheet" type="text/css" />   /*like samirbhogayta: has

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#datepicker").datepicker();
        });

        $(document).ready(function() {
            $("#t").datepicker();
        });
    </script>

</head>
<body>
    <form runat="server">
    <p>
        Date:
        <input type="text" id="datepicker" /></p>
    <input type='button' id='t' value='Show Calendar' onclick='$( "#t" ).datepicker( "show");' />
    </form>
</body>
</html>
0
 
LVL 9

Assisted Solution

by:Roman Gherman
Roman Gherman earned 2000 total points
ID: 35131639
I'm glad it has helped you.

By the way you can download a theme from jQuery UI, you can even customize one by yourself there.

------------------------
You can find me on: www.extremedev.blogspot.com
0
 

Author Closing Comment

by:goodk
ID: 35132780
thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question