Richard Korts
asked on
Jquery DatePicker
I'm trying to use Jquery datepicker in an html page.
I took the example off the Jquery API, adjusted it & ran in on my web server. My revised version is attached; It works perfectly.
Then I adapted my "real" page to use it; here is the Jquery part of that page:
<link rel="stylesheet" href="//code.jquery.com/ui /1.11.2/th emes/smoot hness/jque ry-ui.css" >
<script src="//code.jquery.com/jqu ery-1.10.2 .js"></scr ipt>
<script src="//code.jquery.com/ui/ 1.11.2/jqu ery-ui.js" ></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery/jquery.lightbo x_me.js">< /script>
<script>
$(function() {
$( "#adddate" ).datepicker();
});
$(function() {
$( "#datecompl" ).datepicker();
});
</script>
In the html:
<td width="12%"><input type="text" name="adddate" id="adddate" size="10"></td>
and
<td><input name="datecompl" id="datecompl" type="text" class="pt12" size="12" readonly="readonly"></td>
When you click the mouse on either input field, nothing happens.
In the FireFox Webconsole, it says:
TypeError: $(...).datepicker is not a function
referring to the line $( "#adddate" ).datepicker();
What's wrong?
jq-datepicker-test.htm
I took the example off the Jquery API, adjusted it & ran in on my web server. My revised version is attached; It works perfectly.
Then I adapted my "real" page to use it; here is the Jquery part of that page:
<link rel="stylesheet" href="//code.jquery.com/ui
<script src="//code.jquery.com/jqu
<script src="//code.jquery.com/ui/
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery/jquery.lightbo
<script>
$(function() {
$( "#adddate" ).datepicker();
});
$(function() {
$( "#datecompl" ).datepicker();
});
</script>
In the html:
<td width="12%"><input type="text" name="adddate" id="adddate" size="10"></td>
and
<td><input name="datecompl" id="datecompl" type="text" class="pt12" size="12" readonly="readonly"></td>
When you click the mouse on either input field, nothing happens.
In the FireFox Webconsole, it says:
TypeError: $(...).datepicker is not a function
referring to the line $( "#adddate" ).datepicker();
What's wrong?
jq-datepicker-test.htm
What happens if you don't use Scheme-less URL?
It seams that this does not work if you open the html file locally!
It seams that this does not work if you open the html file locally!
Yes it won't work locally because of the scheme-less URL. If you view it locally it will try to load "file://code.jquery....."
Remove the line:
And add "http:" to the other 2 lines where you have "//code........." and make them "http://code......"
then it should work.
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
As you have another script tag that includes jquery-latest.min.js.And add "http:" to the other 2 lines where you have "//code........." and make them "http://code......"
then it should work.
ASKER
To Brian Tao,
I believe I did what you said. Doesn't work.
So I applied the same changes to the test page (that previously worked), now it doesn't work.
The revised version of that is attached.
FireFox web console gives this:
ReferenceError: jQuery is not defined jquery-ui.js:14
ReferenceError: $ is not defined
If we can get the test version to work, maybe I can try the real page
Thanks
jq-datepicker-test.htm
I believe I did what you said. Doesn't work.
So I applied the same changes to the test page (that previously worked), now it doesn't work.
The revised version of that is attached.
FireFox web console gives this:
ReferenceError: jQuery is not defined jquery-ui.js:14
ReferenceError: $ is not defined
If we can get the test version to work, maybe I can try the real page
Thanks
jq-datepicker-test.htm
ASKER
To all,
I got the test version to work by adding this back in:
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
I also added it to the "real" page; real page does not work.
Here are the applicable elements of the real page:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery/jquery.lightbo x_me.js">< /script>
<script>
$(document).ready(function () {
$('#button').click(functio n(e) {
$('#as_built').lightbox_me ({
closeClick: true,
});
e.preventDefault();
});
});
$(function() {
$( "#adddate" ).datepicker();
$( "#datecompl" ).datepicker();
});
</script>
HTML:
<tr>
<td align="right">Date Completed: </td>
<td><input name="datecompl" id="datecompl" type="text" class="pt12" size="12" readonly="readonly"></td>
</tr>
FireFox Web Console says:
TypeError: $(...).datepicker is not a function (refers to the line $( "#adddate" ).datepicker();)
Note the lightbox thing has nothing to do with this, I included it in case it was somehow connected to making it not work.
Thanks
I got the test version to work by adding this back in:
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
I also added it to the "real" page; real page does not work.
Here are the applicable elements of the real page:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery/jquery.lightbo
<script>
$(document).ready(function
$('#button').click(functio
$('#as_built').lightbox_me
closeClick: true,
});
e.preventDefault();
});
});
$(function() {
$( "#adddate" ).datepicker();
$( "#datecompl" ).datepicker();
});
</script>
HTML:
<tr>
<td align="right">Date Completed: </td>
<td><input name="datecompl" id="datecompl" type="text" class="pt12" size="12" readonly="readonly"></td>
</tr>
FireFox Web Console says:
TypeError: $(...).datepicker is not a function (refers to the line $( "#adddate" ).datepicker();)
Note the lightbox thing has nothing to do with this, I included it in case it was somehow connected to making it not work.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$(function() {
$( "#adddate" ).datepicker();
$( "#datecompl" ).datepicker();
});