0

I have jquery calendar code like this

<script>
$(document).ready(function() {
    $('#calTwo').jCal({
        day: new Date( (new Date()).setMonth( (new Date()).getMonth() + 2 ) ),
        days: 7,
        showMonths: 1,
        monthSelect:    true
    });
});
</script>

And in my body contest as follows

<body>
<span id="calTwo"></span>
</body>

The above code is working fine but my requirement is instead of using span id tag i need to use text field and adjacent to the text field one calendar image. By clicking on that image calendar should get displayed, and whatever the date i have selected that should be shown in the text field.

I am new to Jquery and no idea how to implement this feature Any help.?

2 Answers 2

1

Instead of using jCal, you could also use jQuery UI datepicker

HTML:

Date: <input id="calTwo" type="text"></input>​

Javascript:

$(document).ready(function() {
    $('#calTwo').datepicker().option({"setDate": new Date()});
});​

Example: http://jsfiddle.net/YQ7k8/ The example is ugly because jsfiddle doesn't have jQuery UI css. Take a look at http://jqueryui.com/demos/datepicker/ to see how it might look with the right theme.

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

Comments

0

Something like:

<input id="calTwo" /> <img src="..." id="calTwoIcon" />

<script>
$('#calTwoIcon').click(function() {
    $('#calTwo').focus();
});
</script>

Is that what you were looking for? I just placed an image and assigned a click event that upon getting called will focus the calendar input which should bring up the calendar. Alternatively you could do $('#calTwo').trigger('click');.

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.