developed a web page with two text boxes and a button labelled show.The user can enter a number in the first text box.On clicking the second text box should display the day corresponding to the given number using switch statement in java script
Answers
Answered by
3
◆Hello There◆
function days(dayOfTheWeek) { var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; var n = weekday[dayOfTheWeek]; return n; }
function days(dayOfTheWeek) { var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; var n = weekday[dayOfTheWeek]; return n; }
Answered by
1
<input type="text"
name="text1" id="text1" />
<input type="button" value="Click me"
onclick="
javascript:days(
parseInt(document.getElementById('text1').value));"
/> <script language=javascript>
function days(dayOfTheWeek)
{ switch (dayOfTheWeek)
{
case 1: alert("It\’s Monday"); break;
case 2: alert("It\’s Tuesday"); break
; case 3: alert("It\’s Wednesday"); break
; case 4: alert("It\’s Thursday"); break
; case 5: alert("It\’s Friday"); break;
case 6: alert("It\’s Saturday"); break
; case 7: alert("It\’s Sunday"); break; default: alert("Not a valid day"); break; } }
</script>
name="text1" id="text1" />
<input type="button" value="Click me"
onclick="
javascript:days(
parseInt(document.getElementById('text1').value));"
/> <script language=javascript>
function days(dayOfTheWeek)
{ switch (dayOfTheWeek)
{
case 1: alert("It\’s Monday"); break;
case 2: alert("It\’s Tuesday"); break
; case 3: alert("It\’s Wednesday"); break
; case 4: alert("It\’s Thursday"); break
; case 5: alert("It\’s Friday"); break;
case 6: alert("It\’s Saturday"); break
; case 7: alert("It\’s Sunday"); break; default: alert("Not a valid day"); break; } }
</script>
Similar questions
Math,
8 months ago
Science,
8 months ago
Social Sciences,
1 year ago
India Languages,
1 year ago
World Languages,
1 year ago
Math,
1 year ago