Thursday, 15 April 2010

jquery - Trying to get the date from the bootstrap datepicker to working right -



jquery - Trying to get the date from the bootstrap datepicker to working right -

basically, date take goto textbox. since it's not putting date straight startdatetextbox.value, can't access date on startdatetextbox. there way prepare this?

<script> $(function () { $("#startdatetextbox").datepicker({ showon: "button", buttonimage: "./calendarfull.png", buttonimageonly: true }); document.getelementbyid('startdatetextbox').value = $("startdatetextbox").valueof(); var sdf = 234; } ); </script> <script> $("startdatetextbox").click(function (event) { alert($(this).attr("data-my-custom-data")); alert($(this).attr("data-row-id")); alert($(this).attr("href")); event.preventdefault(); // avoid browsing href... }); document.getelementbyid('startdatetextbox').value = " 234 "; </script>

i'm going effort reply before reply comments on question:

when encounter problem (and posted code i'm guessing you've been doing try-and-see-what-happens approach solving problem), go basics. start fresh page has want on it: references jquery, bootstrap, , date-picker library, plus bare minimum test ui , script.

try this: add together text box t o page: <input type="text" value="" id="startdatetextbox" />, next code: <script type="text/javascript"> $(document).ready(function () { $("#startdatetextbox").datepicker({ showon: "button", buttonimage: "./calendarfull.png", buttonimageonly: true }); }); </script>

i've tested code , know works. generates pop-up date picker when focus on text box, , adds date select text box. , notice i've used $(document).ready()? help ensure libraries have loaded first before initialise date-picker.

i see you're mixing both native javascript selectors , jquery. pick 1 , stick save confusion in switching between styles. jquery works well, suggest utilize that.

now, want access selected date in textbox? seek this: function showdatevalue() { alert($("#startdatetextbox").val()); } should display day textbox in alert dialog.

what need next? see you're referencing hrefs , talking stopping browsing links, suspect there more problem. step me through , can help.

jquery asp.net twitter-bootstrap datepicker bootstrap-datepicker

No comments:

Post a Comment