Can anybody help me to use combobox from Javascript function [modified]
-
Post back is the only problem for me I dont want to use it. I want to display a Date field with three combo boxes. When month and year are selected, automatically the days combo must me filled with those many number of days according to leap or not and then 31 or 30 like that. I want to do all this stuff using Javascript function. So please help me if any body could do it. Thank you.
S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.
-
Post back is the only problem for me I dont want to use it. I want to display a Date field with three combo boxes. When month and year are selected, automatically the days combo must me filled with those many number of days according to leap or not and then 31 or 30 like that. I want to do all this stuff using Javascript function. So please help me if any body could do it. Thank you.
S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.
Try this javascript man...
function GetDayOfMonth(DayCtrlName, MonthCtrlName, YearCtrlName){
var DayCtrl=document.getElementById(DayCtrlName);
var MonthCtrl=document.getElementById(MonthCtrlName);
var YearCtrl=document.getElementById(YearCtrlName);
var lastDayValue=DayCtrl.value;
var DaysCount=31;
if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='2' &&
(parseInt(YearCtrl.options[YearCtrl.selectedIndex].value)%4)==0){
DaysCount=29;
}else if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='2'){
DaysCount=28;
}else if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='4' ||
MonthCtrl.options[MonthCtrl.selectedIndex].value=='6' ||
MonthCtrl.options[MonthCtrl.selectedIndex].value=='9' ||
MonthCtrl.options[MonthCtrl.selectedIndex].value=='11'){
DaysCount=30;
}
DayCtrl.options.length=0;
var oOption;
for (var i=1;i<=DaysCount;i++){
oOption = document.createElement('option');
DayCtrl.options.add(oOption);
oOption.innerHTML=i;
oOption.value=i;
if (i==lastDayValue) oOption.selected=true;
}
}Regards, Venkatesh Mookkan. Software Engineer
-
Post back is the only problem for me I dont want to use it. I want to display a Date field with three combo boxes. When month and year are selected, automatically the days combo must me filled with those many number of days according to leap or not and then 31 or 30 like that. I want to do all this stuff using Javascript function. So please help me if any body could do it. Thank you.
S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.
var elSel = document.getElementById('selectX'); if (elSel.selectedIndex >= 0) { var elOptNew = document.createElement('option'); elOptNew.text = 'Insert' + num; elOptNew.value = 'insert' + num; var elOptOld = elSel.options[elSel.selectedIndex]; try { elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew, elSel.selectedIndex); // IE only } Thanks Rastgar
-
var elSel = document.getElementById('selectX'); if (elSel.selectedIndex >= 0) { var elOptNew = document.createElement('option'); elOptNew.text = 'Insert' + num; elOptNew.value = 'insert' + num; var elOptOld = elSel.options[elSel.selectedIndex]; try { elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew, elSel.selectedIndex); // IE only } Thanks Rastgar
I tried to connect in this way the javascript function to "OnSelectedIndexChanged" event hanlder. But Its not giving me any thing. Means its not adding this "Javascript" function to the event. What may be the problem. If you can please help me by giving some code snippet too please. ddlMonRes.Attributes.Add("OnSelectedIndexChanged", "GetDayOfMonth1();")
S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.
-
var elSel = document.getElementById('selectX'); if (elSel.selectedIndex >= 0) { var elOptNew = document.createElement('option'); elOptNew.text = 'Insert' + num; elOptNew.value = 'insert' + num; var elOptOld = elSel.options[elSel.selectedIndex]; try { elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew, elSel.selectedIndex); // IE only } Thanks Rastgar
I tried to connect in this way the javascript function to "OnSelectedIndexChanged" event hanlder. But Its not giving me any thing. Means its not adding this "Javascript" function to the event. What may be the problem. If you can please help me by giving some code snippet too please. ddlMonRes.Attributes.Add("OnSelectedIndexChanged", "GetDayOfMonth1();")
S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.
-
I tried to connect in this way the javascript function to "OnSelectedIndexChanged" event hanlder. But Its not giving me any thing. Means its not adding this "Javascript" function to the event. What may be the problem. If you can please help me by giving some code snippet too please. ddlMonRes.Attributes.Add("OnSelectedIndexChanged", "GetDayOfMonth1();")
S/W Engineer Akebono Soft Technologies aleem_abdul@akebonosoft.com.
OnSelectedIndexChanged
is a serverside event handler. The javascript corespondent inonChange
.regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.