habib009pk Posted October 3, 2009 Share Posted October 3, 2009 Dear Friends I am using this code function CheckAll(chk) { for (i = 0; i < chk.length; i++) chk.checked = true ; } function show_now(){ var my_day=new Date() //var dt = new Date(\"Aug 16, 2005 05:55:00\"); var day_name=new Array(7); day_name[0]="Sunday" day_name[1]="Monday" day_name[2]="Tuesday" day_name[3]="Wednesday" day_name[4]="Thursday" day_name[5]="Friday" day_name[6]="Saturday" day_name=day_name[my_day.getDay()]; if(day_name=="Sunday") { document.getElementById('day_7').checked = true; CheckAll(document.getElementsByName('day7[]')); } else if(day_name=="Monday") { document.getElementById('day_1').checked = true; CheckAll(document.getElementsByName('day1[]')); } else if(day_name=="Tuesday") { document.getElementById('day_2').checked = true; CheckAll(document.getElementsByName('day2[]')); } else if(day_name=="Wednesday") { document.getElementById('day_3').checked = true; CheckAll(document.getElementsByName('day3[]')); } else if(day_name=="Thursday") { document.getElementById('day_4').checked = true; CheckAll(document.getElementsByName('day4[]')); } else if(day_name=="Friday") { document.getElementById('day_5').checked = true; CheckAll(document.getElementsByName('day5[]')); } else if(day_name=="Saturday") { document.getElementById('day_6').checked = true; CheckAll(document.getElementsByName('day6[]')); } } This code i am using for the checking of Check boxes according to day, this code is perfectly working i called the Function "show_now()" on the onclick funtion but it is not working on the onload function, as i want to use that code on onload function. i want that when i refresh the page the a series of checkbox which are according to the daywise has been selected according to today. and this action has been perform when i refresh the page so that is my problem when i use that code on the onclick it is working nicely but when i use it on onload it is not working which is my requirement. for calling of function on Onload event i am using that code <script language="javascript" type="text/javascript"> window.onLoad = show_now(); </script> Kindly help me regarding this i will be very thankfull Link to comment https://forums.phpfreaks.com/topic/176379-checking-of-checkboxes/ Share on other sites More sharing options...
MadTechie Posted October 3, 2009 Share Posted October 3, 2009 try putting it in the the body tags ie <body onload="show_now();" > Link to comment https://forums.phpfreaks.com/topic/176379-checking-of-checkboxes/#findComment-929623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.