
allego i file che stò facendo sperando che possa esserti di aiuto; mi scuso se non ho postato bene il codice è solo che non sono molto brava in materia.tempestaluna ha scritto:Ho provato a fare come mi avevi detto ma non funzionaallego i file che stò facendo sperando che possa esserti di aiuto; mi scuso se non ho postato bene il codice è solo che non sono molto brava in materia.

function isTimeToShow(06,01,2009,10){
var giorniPerMese = new Array( '31','28','31','30','31','30','31','31','30','31','30','31');
endDay = parseInt(gg)+parseInt(durata);
endMonth = parseInt(mm);
endYear = parseInt(aaaa);
while( endDay > giorniPerMese[endMonth -1] ){
endDay -= giorniPerMese[endMonth -1];
endMonth++;
if(endMonth > 12){
endMonth = 1;
endYear++;
}
}
var end = Date.parse(endDay +'/'+ endMonth +'/'+ endYear);
var start = Date.parse(gg+'/'+mm+'/'+aaaa);
var now = new Date().getTime();
return (start < now && now < end);
}
for (i=1;i<32;i++){
if( isTimeToShow(i,evento.getMonth()+1,evento.getYear(), 10) ){
id='evento'+i;
document.getElementById(id).style.display = 'none';
}
}
document.getElementById('evento'+div).style.display = 'block';
oDiv = document.getElementById('evento32');
oDiv.style.display='none';
}
/* Mostra Dati*/
function showFormDati() {
oDiv = document.getElementById('dati');
oDiv.style.display='block';
oDiv = document.getElementById('tformDati');
oDiv.style.display='block';
return false;
}//-->
/* Nascondi Dati*/
function hideFormDati() {
oDiv = document.getElementById('dati');
oDiv.style.display='none';
return false;
}//-->
tempestaluna ha scritto:in effetti hai ragione il codice che utilizzo per aprire e nascondere i div del calendario e quindi gli eventi del mio calendario non funziona eppure in un'altra pagina dove ho i moduli di un form non mi da errore e mi fa aprire e nascondere i div che voglio io.
perchè questo codice
- Codice: Seleziona tutto
function isTimeToShow(06,01,2009,10){
var giorniPerMese = new Array( '31','28','31','30','31','30','31','31','30','31','30','31');
endDay = parseInt(gg)+parseInt(durata);
endMonth = parseInt(mm);
endYear = parseInt(aaaa);
while( endDay > giorniPerMese[endMonth -1] ){
endDay -= giorniPerMese[endMonth -1];
endMonth++;
if(endMonth > 12){
endMonth = 1;
endYear++;
}
}
var end = Date.parse(endDay +'/'+ endMonth +'/'+ endYear);
var start = Date.parse(gg+'/'+mm+'/'+aaaa);
var now = new Date().getTime();
return (start < now && now < end);
}
for (i=1;i<32;i++){
if( isTimeToShow(i,evento.getMonth()+1,evento.getYear(), 10) ){
id='evento'+i;
document.getElementById(id).style.display = 'none';
}
}
document.getElementById('evento'+div).style.display = 'block';
oDiv = document.getElementById('evento32');
oDiv.style.display='none';
}
in explore e altri non funziona:
e questo invece
- Codice: Seleziona tutto
/* Mostra Dati*/
function showFormDati() {
oDiv = document.getElementById('dati');
oDiv.style.display='block';
oDiv = document.getElementById('tformDati');
oDiv.style.display='block';
return false;
}//-->
/* Nascondi Dati*/
function hideFormDati() {
oDiv = document.getElementById('dati');
oDiv.style.display='none';
return false;
}//-->
funziona anche su explorer?
che differenza c'è?
function getElemById(id){
if(document.getElementById){//Firefox, Opera, Safari, ...
return document.getElementById(id);
}else{//Internet Explorer
return document.all[id];
}
}
function isTimeToShow(06,01,2009,10){
var giorniPerMese = new Array( '31','28','31','30','31','30','31','31','30','31','30','31');
endDay = parseInt(gg)+parseInt(durata);
endMonth = parseInt(mm);
endYear = parseInt(aaaa);
while( endDay > giorniPerMese[endMonth -1] ){
endDay -= giorniPerMese[endMonth -1];
endMonth++;
if(endMonth > 12){
endMonth = 1;
endYear++;
}
}
var end = Date.parse(endDay +'/'+ endMonth +'/'+ endYear);
var start = Date.parse(gg+'/'+mm+'/'+aaaa);
var now = new Date().getTime();
return (start < now && now < end);
}
for (i=1;i<32;i++){
if( isTimeToShow(i,evento.getMonth()+1,evento.getYear(), 10) ){
id='evento'+i;
document.getElementById(id).style.display = 'none';
}
}
document.getElementById('evento'+div).style.display = 'block';
oDiv = document.getElementById('evento32');
oDiv.style.display='none';
}
//-->
La differenza sta probabilmente nel fatto che quello del form l'hai collegato ad un link o all'evento onlick di qualche elemento...
In ogni caso anche il codice dei form su explorer non funzionerà perché explorer non ha il metodo document.getElementById('idElemento') ma devi usare document.all['idElemento']
/* Mostra Dati*/
function showFormDati() {
oDiv = document.getElementById('dati');
oDiv.style.display='block';
oDiv = document.getElementById('tformDati');
oDiv.style.display='block';
return false;
}//-->
/* Nascondi Dati*/
function hideFormDati() {
oDiv = document.getElementById('dati');
oDiv.style.display='none';
return false;
}//-->
<html>
<head>
<title>Test isTimeToShow()</title>
<script type="text/javascript"><!--
function isTimeToShow(gg,mm,aaaa,durata){
var giorniPerMese = new Array( '31','28','31','30','31','30','31','31','30','31','30','31');
endDay = parseInt(gg)+parseInt(durata);
endMonth = parseInt(mm);
endYear = parseInt(aaaa);
while( endDay > giorniPerMese[endMonth -1] ){
alert('lol???');
endDay -= giorniPerMese[endMonth -1];
endMonth++;
if(endMonth > 12){
endMonth = 1;
endYear++;
}
}
var start = Date.parse(mm+'/'+gg+'/'+aaaa);
var end = Date.parse(endMonth +'/'+ endDay +'/'+ endYear);
var now = new Date().getTime();
return (start < now && now < end);
}
function getElemById(id){
if(document.getElementById){//Firefox, Opera, Safari, ...
return document.getElementById(id);
}else{//Internet Explorer
return document.all[id];
}
}
function controllaDiv(){
for( i = 1; i<=10; i++){
now = new Date();
if( isTimeToShow(i, now.getMonth()+1,now.getFullYear(),10) ){
getElemById('evento'+i).style.display = "none";
}
}
}
--></script>
</head>
<body onload="controllaDiv()">
<div id="evento1">1</div>
<div id="evento2">2</div>
<div id="evento3">3</div>
<div id="evento4">4</div>
<div id="evento5">5</div>
<div id="evento6">6</div>
<div id="evento7">7</div>
<div id="evento8">8</div>
<div id="evento9">9</div>
<div id="evento10">10</div>
</body>
</html>
<a href="#" onClick="isTimeToShow('25')" class="screenshot" rel="../img/m_rilassante.png" title="relax in agriturismo">LAST MINUTE DIQUESTO MESE</a>tempestaluna ha scritto:ho messo come hai detto tu; e l'ho richiamato così:
- Codice: Seleziona tutto
<a href="#" onClick="isTimeToShow('25')" class="screenshot" rel="../img/m_rilassante.png" title="relax in agriturismo">LAST MINUTE DIQUESTO MESE</a>
ma non funziona... non mi fa vedere nulla
isTimeToShow('25', new Date().getMonth()+1,new Date().getFullYear(),10)
tempestaluna ha scritto:ok ma non devo mettere un link per richiamarlo? o mi apre alla data prestabilita il div in automatico non ho capito
...
<body onload="controllaDiv()">
...
<body onload="controllaDiv()">L'ultimo codice che ho postato mostra il div con id eventoX a partire dal giorno X per 10 giorni,
tempestaluna ha scritto:ho fatto copia incolla del javascript e ho messo nel tag bodyma non mi fa vedere nulla.
- Codice: Seleziona tutto
<body onload="controllaDiv()">L'ultimo codice che ho postato mostra il div con id eventoX a partire dal giorno X per 10 giorni,
scusa la mia ignoranza ma dove posso modificare il giorno X? l'evento l'ho capito ma il giorno no
function controllaDiv(){
for( i = 1; i<=10; i++){
now = new Date();
if( isTimeToShow(i, now.getMonth()+1,now.getFullYear(),10) ){
getElemById('evento'+i).style.display = "none";
}
}
}[(code]
<html xmlns="http://www.w3.org/1999/xhtml" lang="it" xml:lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Calendario eventi 2009 agriturismo Il Punto Verde</title>
<link href="../ilpuntoverde/calendario.css" rel="stylesheet" type="text/css" />
<script language="Javascript" type="text/javascript">
<!--
function isTimeToShow(gg,mm,aaaa,durata){
var giorniPerMese = new Array( '31','28','31','30','31','30','31','31','30','31','30','31');
endDay = parseInt(gg)+parseInt(durata);
endMonth = parseInt(mm);
endYear = parseInt(aaaa);
while( endDay > giorniPerMese[endMonth -1] ){
alert('lol???');
endDay -= giorniPerMese[endMonth -1];
endMonth++;
if(endMonth > 12){
endMonth = 1;
endYear++;
}
}
var start = Date.parse(mm+'/'+gg+'/'+aaaa);
var end = Date.parse(endMonth +'/'+ endDay +'/'+ endYear);
var now = new Date().getTime();
return (start < now && now < end);
}
function getElemById(id){
if(document.getElementById){//Firefox, Opera, Safari, ...
return document.getElementById(id);
}else{//Internet Explorer
return document.all[id];
}
}
-->
</script>
<script language="Javascript" src="../ilpuntoverde/jquery.js" type="text/javascript"></script>
<script language="Javascript" src="../ilpuntoverde/main.js" type="text/javascript"></script>
</head>
<body onload="controllaDiv()">
<div id="corpo">
<div id="corpoalto">
<h2 class="w_link">Al momento non sono presenti OFFERTE
LAST MINUTE DIQUESTO MESE</h2>
<script type="text/javascript">
function controllaDiv(){
for( i = 1; i<=10; i++){
now = new Date();
isTimeToShow('25', new Date().getMonth()+1,new Date().getFullYear(),10){
getElemById('evento'+i).style.display = "none";
}
}
</script>
<div id="evento1"></div>
<div id="evento2"></div>
<div id="evento3"></div>
<div id="evento4"></div>
<div id="evento5"></div>
<div id="evento6"></div>
<div id="evento7"></div>
<div id="evento8"></div>
<div id="evento9"></div>
<div id="evento10"></div>
<div id="evento11"></div>
<div id="evento12"></div>
<div id="evento13"></div>
<div id="evento14"></div>
<div id="evento15"></div>
<div id="evento16"></div>
<div id="evento17"></div>
<div id="evento18"></div>
<div id="evento19"></div>
<div id="evento20"></div>
<div id="evento21"></div>
<div id="evento22"></div>
<div id="evento23"></div>
<div id="evento24"></div>
<div id="evento25"></div>
<div id="evento26"></div>
</div>
</div>
</body>
</html>

, vediamo se così sono un po' più chiara:
function nascondi(div){
for (i=1;i<32;i++){
id='evento'+i;
document.getElementById(id).style.display = 'none';
}
document.getElementById('evento'+div).style.display = 'block';
oDiv = document.getElementById('evento32');
oDiv.style.display='none';
}
function getElemById(id){
if(document.getElementById){//Firefox, Opera, Safari, ...
return document.getElementById(id);
}else{//Internet Explorer
return document.all[id];
}
}
<html>
<head>
<title>Esempio calendario</title>
<script type="text/javascript"><!--
eventiDaCaricare = new Array(
//Descrizione
//Ogni riga deve essere così formata:
// ["numero del div", "data di inizio", "data di fine"]
//NB. Le date sono nella forma MESE / GIORNO / ANNO
//Es. Mostrare il div evento1 a partire dal 1 gennaio 2009 fino al 21 gennaio 2009
["1", "01/01/2009", "01/21/2009" ],
["2", "01/10/2009", "01/21/2009" ],
["3", "01/01/2009", "01/21/2009" ],
["4", "01/10/2009", "01/21/2009" ],
["5", "01/01/2009", "01/21/2009" ],
["6", "01/10/2009", "01/21/2009" ],
["7", "01/01/2009", "01/21/2009" ],
["8", "01/10/2009", "01/21/2009" ],
["9", "01/01/2009", "01/21/2009" ],
["10", "01/10/2009", "01/21/2009" ]
);
function isTimeToShow(dataInizio, dataFine){
inizio = Date.parse(dataInizio);
fine = Date.parse(dataFine);
adesso = new Date().getTime();
return inizio <= adesso && adesso <= fine;
}
function getElemById(id){
if(document.getElementById){//Firefox, Opera, Safari, ...
return document.getElementById(id);
}else{//Internet Explorer
return document.all[id];
}
}
function caricaEventi(){
for( i=0; i<eventiDaCaricare.length; i++){
try{
if (isTimeToShow(eventiDaCaricare[i][1],eventiDaCaricare[i][2])){
getElemById("evento"+(i+1)).style.display = "";
}else{
getElemById("evento"+(i+1)).style.display = "none";
}
}catch(eccezione){}
}
}
--></script>
</head>
<body onload="caricaEventi()">
<div id="evento1">1</div>
<div id="evento2">2</div>
<div id="evento3">3</div>
<div id="evento4">4</div>
<div id="evento5">5</div>
<div id="evento6">6</div>
<div id="evento7">7</div>
<div id="evento8">8</div>
<div id="evento9">9</div>
<div id="evento10">10</div>
</body>eventiDaCaricare = new Array(
//Descrizione
//Ogni riga deve essere così formata:
// ["numero del div", "data di inizio", "data di fine"]
//NB. Le date sono nella forma MESE / GIORNO / ANNO
//Es. Mostrare il div evento1 a partire dal 1 gennaio 2009 fino al 21 gennaio 2009
["1", "01/01/2009", "01/21/2009" ],
["2", "01/10/2009", "01/21/2009" ],
["3", "01/01/2009", "01/21/2009" ],
["4", "01/10/2009", "01/21/2009" ],
["5", "01/01/2009", "01/21/2009" ],
["6", "01/10/2009", "01/21/2009" ],
["7", "01/01/2009", "01/21/2009" ],
["8", "01/10/2009", "01/21/2009" ],
["9", "01/01/2009", "01/21/2009" ],
["10", "01/10/2009", "01/21/2009" ]
);
Bravo!!!! ti ringrazio tanto non sai quanto, per di più hai avuto una pazienza infinita con me; adesso non mi rimane che cambiare l'id dei miei div da id="evento1" a id="1" e funziona tutto!!!!

tempestaluna ha scritto:![]()
Bravo!!!! ti ringrazio tanto non sai quanto, per di più hai avuto una pazienza infinita con me; adesso non mi rimane che cambiare l'id dei miei div da id="evento1" a id="1" e funziona tutto!!!!
l'ho provato anche su explorer 7.0 e safari nonchè firefox 2.0 e funziona bene
grazie grazie grazie!!!!!!


Visualizzano questa pagina: Andreahma, djluka89, ele_girasole e 2 ospiti