Avatar billede stig69 Nybegynder
20. februar 2003 - 08:40 Der 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?

Min kode:

echo " måned: <select name=month><option value=01>januar<option value=02>februar<option value=03>marts [... osv...] <option value=12>december</select>";

echo " Dag: <select name=day><option value=01>01<option value=02>02 [...osv...] <option value=29>29<option value=30>30<option value=31>31</select>";

Stig
Avatar billede medions Nybegynder
20. februar 2003 - 09:43 #1
<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

//>Rune
Avatar billede medions Nybegynder
20. februar 2003 - 09:54 #2
<html>
<head>
    <title></title>
<script language="VBScript">
arrMonths = Array("Januar", "Februar", "Marts", "April", "Marts", "April", "Maj", "Juni", "Juli", "August", "Oktober", "November", "December")
document.write("<select name='Mdr'>")
    For i = 0 To 12
        document.write("<option value='" & arrMonths(i) & "'>" & arrMonths(i))
    Next
document.write("</select>")
</script>
</head>
<body>

</body>
</html>

//>Rune
Avatar billede stig69 Nybegynder
20. februar 2003 - 09:57 #3
Man kan ikke lave det i php vel? Det skal være i VBScript eller JavaScript? Skal jeg kalde funktionen nede i body?
Avatar billede medions Nybegynder
20. februar 2003 - 09:58 #4
2 sek, lad mig lige lave det færdigt! ;o)

//>Rune
Avatar billede stig69 Nybegynder
20. februar 2003 - 10:06 #5
Jeg venter med spænding ;-)
Avatar billede medions Nybegynder
20. februar 2003 - 10:21 #6
<html>
<head>
    <title></title>
<script language="VBScript">
Sub Mdr_OnChange()
    MsgBox(me.selectedIndex)
End Sub

arrMonths = Array("Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December")
document.write("<form name='frm1'>")
document.write("<select name='Mdr'>")
    For i = 0 To 12
        document.write("<option value='" & arrMonths(i) & "'>" & arrMonths(i))
    Next
document.write("</select>")
document.write("</form>")
</script>
</head>
<body>

</body>
</html>

Her har du lidt mere ;o)
-er stadivæk igang *G*

//>Rune
Avatar billede medions Nybegynder
20. februar 2003 - 10:35 #7
Sådan...

<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))

    'Set objEntry = document.createElement("Option")
    'strtekst = formbegivenhedstype.begivenhedstype.value
    'objEntry.text = strtekst
    'objEntry.value = strtekst
       
    'frm1.Days.add 123
End Sub

arrMonths = Array("Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December")
</script>
</head>
<body>

<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>

</body>
</html>

//>Rune
Avatar billede medions Nybegynder
20. februar 2003 - 10:41 #8
<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

arrMonths = Array("Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December")
</script>
</head>
<body>

<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!
        */
    }
?>

</body>
</html>

//>Rune
Avatar billede stig69 Nybegynder
20. februar 2003 - 10:56 #9
Det er flot arbejde! Jeg kan skal lige kæmpe lidt med det. Jeg kan nemlig ikke VBScript, men du har fortjent dine point. Tak for hjælpen :-)
Avatar billede medions Nybegynder
20. februar 2003 - 10:58 #10
Anytime ;o)
Thx 4 Poinz

//>Rune
Avatar billede Ny bruger Nybegynder

Din løsning...

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester