Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What I have tried:

<html>
<head>
<script language="JavaScript">
function week()
{
var n,day;
n=document.formday.nday.value;
switch(n)
{
case 1:day="monday";
break;
case 2:day="tuesday";
break;
case 3:day="wednesday";
break;
case 4:day="thursday";
break;
case 5:day="friday";
break;
case 6:day="saturday";
break;
case 7:day="sunday";
break;
default:day="invalid input";
break;
}
document.formday.nday.value;
}
</script>
</head>
<body>
<form action="login.php" method="post" name="formday">
daynumber
<input type="text" name="nday">

day
<input type="text" name="txtno">



<input type="button" value="show" onclick="Week()">

</form>
</body>
</html>
Posted
Updated 17-Oct-16 22:23pm
Comments
ZurdoDev 17-Oct-16 13:35pm    
Debug your code and you'll find the problem very quickly.
[no name] 17-Oct-16 13:43pm    
It's customary to ask a question. Just dumping your code here implies that you expect us to read your mind to know what you problem is.

Javascript
JavaScript
function week()

HTML
HTML
<input type="button" value="show" onclick="Week()">

Do you notice the different spellings of week and Week?
 
Share this answer
 
try this

HTML
<html>
<head>
    <script language="JavaScript">
        function week() {
            var n, day;
            n = parseInt( document.formday.nday.value);
            switch (n) {
                case 1: day = "monday";
                    break;
                case 2: day = "tuesday";
                    break;
                case 3: day = "wednesday";
                    break;
                case 4: day = "thursday";
                    break;
                case 5: day = "friday";
                    break;
                case 6: day = "saturday";
                    break;
                case 7: day = "sunday";
                    break;
                default: day = "invalid input";
                    break;
            }
            document.formday.txtno.value = day;
        }
    </script>
</head>
<body>
    <form action="login.php" method="post" name="formday">
        daynumber <input type="text" name="nday">
        day  <input type="text" name="txtno">
        <input type="button" value="show" onclick="week()">

    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900