i have three dropdown in asp.net Day month year
now i chech the wich one is has select and give me message
this is java script
function validdate(obj1,obj2,obj3) { if((document.getElementById(obj1).value=="Day")&&(document.getElementById(obj2).value=="Month")&&((document.getElementById(obj3).value=="Year"))) { document.getElementById('<%=ltmsg.ClientID%>').innerText='Date is mandatory.'; } else if((document.getElementById(obj1).value=="Day")&&(document.getElementById(obj2).value=="Month")) { document.getElementById('<%=ltmsg.ClientID%>').innerText='Date is mandatory.'; } else if(document.getElementById(obj1).value=="Day") { document.getElementById('<%=ltmsg.ClientID%>').innerText='Date is mandatory.'; } else if(document.getElementById(obj2).value=="Month") { document.getElementById('<%=ltmsg.ClientID%>').innerText='Month is mandatory.'; } else if(document.getElementById(obj3).value=="Year") { document.getElementById('<%=ltmsg.ClientID%>').innerText='Year is mandatory.'; } else { document.getElementById('<%=ltmsg.ClientID%>').innerText=''; } }
|
n this is c# code in form load
ddl_day.Attributes.Add("onchange", "javascript:validdate('" + ddl_day.ClientID + "','" + ddl_month.ClientID + "','" + ddl_year.ClientID + "');"); ddl_month.Attributes.Add("onchange", "javascript:validdate('" + ddl_day.ClientID + "','" + ddl_month.ClientID + "','" + ddl_year.ClientID + "');"); ddl_year.Attributes.Add("onchange", "javascript:validdate('" + ddl_day.ClientID + "','" + ddl_month.ClientID + "','" + ddl_year.ClientID + "');");
|
please help me
ArshadPosted Oct 1, 2010, 10:38 AM
You have to keep that java script function in side the body or at the end of the body element, then it will work. coz ur doing runtime binding, might be coz of that ur getting that error. just try once.
Regards,
Arshad
Suthish NairPosted Sep 30, 2010, 4:51 PM
Try hardcoding ClientID...
document.getElementById('<%=ddl_day.ClientID%>').value
Dharmesh SharmaPosted Sep 30, 2010, 8:51 AM
Raghavendra u
now i m geting this error
Microsoft JScript runtime error: Object expected
Raghavendra UPosted Sep 30, 2010, 8:36 AM
Dharmesh SharmaPosted Sep 30, 2010, 8:22 AM
Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object
Suthish NairPosted Sep 30, 2010, 8:10 AM
What error you facing... rewrite ur code..
String s = String.Format("javascript:validdate('{0}', '{1}', '{2}')", ddl_day.ClientID , ddl_month.ClientID, ddl_year.ClientID);
ddl_day.Attributes.Add("onchange", s);
ddl_month.Attributes.Add("onchange", s);
ddl_year.Attributes.Add("onchange", s);