Results 1 to 6 of 6

Thread: How to call the javascript code on click of the calendar icon

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Answers
    3

    How to call the javascript code on click of the calendar icon

    Hi, I am working on a project where I will be creating textbox to eneter date and a calendar icon dynamically. I have a javascript code for a popup calendar. my problem is that i don't know how to call the javascript code on click of the calendar icon and pass the value to the textbox

    please help me...


  2. #2
    Contributing Member
    Join Date
    May 2007
    Answers
    32

    Re: How to call the javascript code on click of the calendar icon

    hi
    i will give u one code u copy that it will help u
    in the jsp u call like this show_calendar('jspformname.fieldname');
    and in the java script u write that code

    function show_calendar() {

    p_item = arguments[0];
    gNow = new Date();
    var dateArr = new Array();
    if (arguments[1] != null) {
    dateArr = arguments[1].split("/");
    gNow.setFullYear(parseInt(dateArr[2]),parseInt(dateArr[1])-1,parseInt(dateArr[0]));
    }
    if (arguments[2] == null)
    p_month = new String(gNow.getMonth());
    else
    p_month = arguments[2];
    if (arguments[3] == "" || arguments[2] == null)
    p_year = new String(gNow.getFullYear().toString());
    else
    p_year = arguments[3];
    if (arguments[4] == null)
    p_format = "DD/MM/YYYY";
    else
    p_format = arguments[4];

    vWinCal = window.open("", "Calendar",
    "width=250,height=250,status=no,resizable=no,top=200,left=200");
    vWinCal.focus();
    vWinCal.opener = self;

    ggWinCal = vWinCal;

    Build(p_item, p_month, p_year, p_format);
    }

    reply me whether it is executing or not


  3. #3
    Junior Member
    Join Date
    Mar 2007
    Answers
    3

    Re: How to call the javascript code on click of the calendar icon

    Sorry, i forgot to tell u I am coding in vb.net .
    i am having java script code for creating popup calendar which i am calling in html page as shown below.

    </asp:textbox><IMG id="Img1" style="WIDTH: 24px; HEIGHT: 21px" onclick="NewCal('txtDate','mmddyyyy',false,24);"
    height="21" alt="Pick a date" src="../icons/date.ico" width="24" align="absMiddle" border="0" runat="server">

    Now i want to reuse the same javascript code for On click of Image icon which is generated Dynamically in code behind of vb.net


  4. #4
    Junior Member
    Join Date
    Mar 2007
    Answers
    3

    Re: How to call the javascript code on click of the calendar icon

    this is what i have tried to do with java script in code behind of vb.net

    ibg.Attributes.Add("onClick", "javascript:return newcal(txtedate1, mddyyyy, False, 24)")

    this is the javascript function i am goin to call
    where ibg ---> is the image button ID.
    txtedate1 --> is the textbox ID for which i have to specify the date.


  5. #5
    Junior Member
    Join Date
    Dec 2007
    Answers
    18

    Re: How to call the javascript code on click of the calendar icon

    hi yashaswi,

    You can try out in this way
    Code:
    Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
    
                Dim gr As GridViewRow
    
                For Each gr In GridView1.Rows
                    gr.Cells(0).Attributes.Add("onclick", "window.open('ConDet.aspx?id=" & gr.Cells(0).Text & "','popWin','width=600px,height=380px');")
                    
                Next gr
    
            End Sub



  6. #6
    Junior Member
    Join Date
    Jul 2011
    Answers
    1

    Re: How to call the javascript code on click of the calendar icon

    Instead of extra calender image you can use ,Image inside Textbox using css it is very easy .........Try below code:
    .TextBoxDateWaterMarked
    {
    background-image:url(images/calendar_icon.gif);
    background-position:right;
    background-repeat:no-repeat;
    height: 16px;
    width: 140px;
    padding: 2px 2 2 2px;
    border: 1px solid #BEBEBE;
    background-color: #F0F8FF;
    color: Gray;
    font-weight:bold;
    font-size: 10pt;
    text-align: left;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact