Home » OsCommerce, PHP Code, Smarty »

4

Hi friends, In this post i want to explain how to implement events calender in oscommerce. We can schedule the products and we can display the which events/products are schedule in which date. And i have implemented demo in smarty application.

Screenshot of event calendar :

Events calender implementation in oscommerce using php code | Anil Labs

Events calender implementation in oscommerce using php code | Anil Labs

 

 

Call that function in any of your file like :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$year=date('Y');$month=date('m');
?>
<select id="year" name="year" onChange="getResult();">
<?php for($i=2000;$i<2020;$i++){ ?>
<option value="<?php echo $i;?>" <?php if($i==$year){?> selected="selected"<?php }?> ><?php echo $i;?></option>
<?php } ?>
</select>
<select id="month" name="month" onChange="getResult();">
<?php for($i=1;$i<=12;$i++){?>
<option value="<?php echo $i;?>" <?php if($i==$month){?> selected="selected"<?php }?>><?php echo $i;?></option>
<?php } ?>
</select>
</div>
<div id="txtResult" align="center">
<?php
echo generate_calendar($year,$month);
?>

 

Implementation in Ajax functionality:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<script language="javascript" type="text/javascript">

function getResult()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}

year=document.getElementById("year").value;
month=document.getElementById("month").value;
//alert(year);
//alert(month);
document.getElementById('txtResult').innerHTML = "Getting...";
var url="call.php"
url=url+"?year="+year+"&amp;month="+month
//alert(url);
url=url+"&amp;sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtResult").innerHTML=xmlHttp.responseText;
//document.getElementById("hid").value=xmlHttp.responseText;
}

}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

</script>

Related Posts

    We get the address by latitude and longitude -using php codeHow to add HTML content in php mail() functionHow to set the timezone of server using PHPHow to get loaded modules in the server using php code

 

4 Comments

  1. sekhar says:

    Great informations of php code collections. Thanks for sharing.

  2. Great blog,
    Your demo http://labs.anil2u.info/events_calender.php
    is not working.Giving java script error ‘addUnits is not defined’.

  3. anju says:

    Your demo is not working…

  4. @Pragnesh , @Anju , This is demo only. It is displaying the calender only.

Leave a Reply