You need to sign in to do that
Don't have an account?
intern24
help with jquery in my visualforce page
i have been trying to get datepicker to work with my visualforce page. I set it up but i can not get the calendar to pop up.
Here is my code:
<apex:page controller="testController">
<link type="text/css" href="{!URLFOR($Resource.css)}" rel="stylesheet" />
<script type="text/javascript" src="{!URLFOR($Resource.Jquery)}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.core)}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.Datepicker)}"></script>
<input id="datepicker" type="textbox" />
<script type="text/javascript">
$(function() {
$(“#datepicker”).datepicker();
});
</script>
<apex:form >
<apex:inputText value="{!inputValue}" id="datepicker"/><br/>
<apex:commandButton action="{!testAction}" value="testButton"/>
</apex:form>
</apex:page>
Thanks for any help you can give.
View the HTML source of your website, I think that you will find your textbox with an ID="datepicker" does not really have a HTML ID ="datepicker" Visual force like to mess with your HTML and add its own junk into it.
I would recommend using CSS class="datepicket" instead of an ID. Then use jQuery $(“.datepicker”).datepicker();
But if you want to use ID you can do a search in the forum on how to get IDs the syntax is something like
sorry, I do not understand.
Try this
It is still not working. Nothing happens when you click on the textbox
Could it be my static resources? I keep looking looking at the jquery website to see if i have the correct stuff and I do.
do some small steps see if you can do some simple jQuery commands like
alert( $('#datepicker').val() );
could be jQuery is not loaded, use firebug addin to firefox and run JavaScript commands using the console to test/debug
Remember to include all Jquery initializing scripts in
I thought maybe it was the $ operator so i did this:
Still no change.
An alternative is to use the VisualForce date picker, e.g
<apex:inputField value="{!ActiveItinerary.myMaster.Date__c}"></apex:inputField>
Your Visualforce page will look like this:
<head>
<apex:includeScript value="{!URLFOR($Resource.JQuery1_8, '/js/jquery-1.8.0.min.js')}" />
<apex:includeScript value="{!URLFOR($Resource.JQuery1_8, '/js/jquery-ui-1.8.23.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.JQuery1_8, '/css/ui-lightness/jquery-ui-1.8.23.custom.css')}" />
<script>
$(function() {
$('[id$=datepicker]').datepicker({dateFormat: 'yy-mm-dd'})
});
</script>
And your apex:inputText will look like this:
<apex:inputText value="{!FromDate}" id="datepicker"/>
Make sure that the id specified in your apex:inputText is the same as the [id$=] specified in your JQuery expression