20. februar 2003 - 08:40Der er
9 kommentarer og 1 løsning
Drop down menu
Jeg har lavet to drop down menuer. Jeg vil gerne have at hvis man vælger januar, marts osv., så kan man vælge mellem datoerne [0;31]. Hvis man derimod vælger månederne april, juni osv. skal man kun kunne vælge mellem datoerne [0;30] og hvis man vælger februar så datoerne [0;29]. Hvorledes gøres dette?
<script language="VBScript"> Function DaysInMonth(Month, Year) If Month<1 or Month>12 then DaysInMonth=0 If Month=1 then DaysInMonth=31 If Month=3 then DaysInMonth=31 If Month=5 then DaysInMonth=31 If Month=7 then DaysInMonth=31 If Month=8 then DaysInMonth=31 If Month=10 then DaysInMonth=31 If Month=12 then DaysInMonth=31 If Month=4 then DaysInMonth=30 If Month=6 then DaysInMonth=30 If Month=9 then DaysInMonth=30 If Month=11 then DaysInMonth=30 If Month=2 then If Year/4=int(Year/4) then If Year/100=int(Year/100) then If Year/400=int(Year/400) then DaysInMonth=29 else DaysInMonth=28 End If Else DaysInMonth=29 End If Else DaysInMonth=28 End If End If
<html> <head> <title></title> <script language="VBScript"> Function DaysInMonth(Month, Year) If Month<1 or Month>12 then DaysInMonth=0 If Month=1 then DaysInMonth=31 If Month=3 then DaysInMonth=31 If Month=5 then DaysInMonth=31 If Month=7 then DaysInMonth=31 If Month=8 then DaysInMonth=31 If Month=10 then DaysInMonth=31 If Month=12 then DaysInMonth=31 If Month=4 then DaysInMonth=30 If Month=6 then DaysInMonth=30 If Month=9 then DaysInMonth=30 If Month=11 then DaysInMonth=30 If Month=2 then If Year/4=int(Year/4) then If Year/100=int(Year/100) then If Year/400=int(Year/400) then DaysInMonth=29 else DaysInMonth=28 End If Else DaysInMonth=29 End If Else DaysInMonth=28 End If End If End Function
Sub Mdr_OnChange() MsgBox(DaysInMonth(me.selectedIndex, 2003))
<html> <head> <title></title> <script language="VBScript"> Function DaysInMonth(Month, Year) If Month<1 or Month>12 then DaysInMonth=0 If Month=1 then DaysInMonth=31 If Month=3 then DaysInMonth=31 If Month=5 then DaysInMonth=31 If Month=7 then DaysInMonth=31 If Month=8 then DaysInMonth=31 If Month=10 then DaysInMonth=31 If Month=12 then DaysInMonth=31 If Month=4 then DaysInMonth=30 If Month=6 then DaysInMonth=30 If Month=9 then DaysInMonth=30 If Month=11 then DaysInMonth=30 If Month=2 then If Year/4=int(Year/4) then If Year/100=int(Year/100) then If Year/400=int(Year/400) then DaysInMonth=29 else DaysInMonth=28 End If Else DaysInMonth=29 End If Else DaysInMonth=28 End If End If End Function
Sub Mdr_OnChange() 'MsgBox(DaysInMonth(me.selectedIndex, Year(Date()))) document.location = "getDayesInMonth.php?days=" & DaysInMonth(me.selectedIndex, Year(Date())) End Sub
<form name="frm1"> <script language="VBScript"> document.write("<select name='Mdr'>") For i = 0 To 12 document.write("<option value='" & arrMonths(i) & "'>" & arrMonths(i) & "</option>") Next document.write("</select>") </script>
<? if ($_REQUEST['Days'] <> "") { /* Jeg kan ikke PHP, men det er ret simpelt! Hvis din QueryString er lig med et eller andet, så lav en løkke hvor du skriver tallene fra 0 til antal date i din QueryString, i en selectbox! */ } ?>
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.