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...
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
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
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 [B]ibg[/B] ---> is the image button ID.
txtedate1 --> is the textbox ID for which i have to specify the date.
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
[/CODE]
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;
}