0

I am having trouble getting my datepicker to popup on an image click and sending the selected input to my text entry field. Basically, when the user clicks on the calender image, the datepicker popup should appear, they choose an input, and it appears in the text input. Also, I need the text input to show the proper date on the calender if they input a date then check the calender. Here is my input and image section.

<p>Date: <input type="text" class="screening_01" id="screening_01" maxlength="10" size="10" value="<%=session.getAttribute("screening_01")==null?"":session.getAttribute("screening_01")%>" /></p>
<div id="calender"><img src="/images/calendar.png" /></div>

This is a working datepicker, but it only works if I click the text input itslef.

$(function() {
    $( "#screening_01" ).datepicker();
});

Now I need it to popup when I click the calender image or div, maybe something like this? (not working of course)

$("#calender").click(function() {
       $("#datepicker").show(); 
    });
0

4 Answers 4

2

This is what you are looking for, using the show method:

$("#calender").click(function() {
   $("#screening_01").datepicker( "show" );
});

When in doubt, always look in the API Reference: http://api.jqueryui.com/datepicker/#method-show

Sign up to request clarification or add additional context in comments.

3 Comments

only thing is I do believe his datepicker id is screening_01
Thank you for the responses. ill try this here shortly!
Man, you guys make it look so easy, I am still an intro programmer, I am taking c# now, but javascript later.
0

use show option of datepicker and call it in #screening_01

$("#calender").click(function() {
  $( "#screening_01" ).datepicker('show');
});

Comments

0

May be this will help you...

$( "#screening_01" ).datepicker({
  showOn: "button",
  buttonImage: "images/calendar.gif",
  buttonImageOnly: true
});

For reference: http://jqueryui.com/datepicker/#icon-trigger

Comments

0

The datepicker already has an option to trigger on an icon image.

$( "#datepicker" ).datepicker({
      showOn: "both", //image click and focus on input field
      buttonImage: "images/calendar.gif",
      buttonImageOnly: true
    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.