SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2013
    Location
    USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to hide or show calendar image (datepicker) based on date value in the text box

    This application allows user to select report criteria fields and then save the report query. There is already a javascript functin 'showDP' which makes calendar icon visible next to the text box if user selects a criteria field type which requires date value in the text box. The calendar icon (datepicker) appears next to the text box.

    While this works fine for saving the report query, the problem is that when user retrieves the saved report query by selecting the saved query name, the calendar icon (datepicker) is hidden even if the value in the text box populated form the saved query is date. Therefore, user cannot modify the date.

    I am trying to fix this. I cannot use the javascript function 'showDP' for two reasons. One I don't know how to fire it when the report criteria field values are being populated. Second, the 'showDP' javascript removes the value from the text box and then shows the calendar icon (this is not desired. the date should still be there).

    So, I am wondering if I can use jQuery to show/hide the calendar icon during the 'btnClick_Retrieve' event??

    If yes, how do write this query if the IDs of the controls on the web form are as below:

    Report Criteria Fields value text boxes: txtBox0, txtBox1,txtBox2,txtBox3,txtBox4, and txtBox5
    Calendar icon (datepicker) control: dp0, dp1,dp2,dp3,dp4, and dp5

    I wonder if I have to modify the existing javascript function or the jQuery library has all of those functions built-in and jQuery statement will use them??

    It will be interesting to know and use this great programming tool. I am excited. Please help me understand morel...

    Update1: I have added my html example to jsFiddle. Here is the link: Techie's jsFiddle

    In the example, the jQuery should check the value in txtBox0 and txtBox1. It is date then it should make the calender image 'DP0' and/or 'DP1' visible. Otherwise image will be hidden.

  2. #2
    SitePoint Member
    Join Date
    Aug 2013
    Location
    USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Update 2: I have added my own version of jQuery on jsFiddle. I am not sure if this will work. First off, I am not sure how should the jQuery validate that the data populated by fill method in the text boxes is date or not. Second, I don't know how to fire the jQuery at the appropriate time. Or will it just do what it is supposed to do whenever change in the field value occurs? Need some help here as well.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •