Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Visual Basic 2008 Web applications) The following code does this : (Printing Da

ID: 3625660 • Letter: #

Question

(Visual Basic 2008 Web applications)

The following code does this :
(Printing Dates and various formats) Dates are printed in several common formats. Write a script that reads a date from a XHTML form and creates a Date object in which to store it. Then use the various methods of the Date object that converts Dates into strings to display the date in several formats.

What needs to be changed :
Get the date input from a window.prompt input object as opposed to using a form as the problem statement specifies.

OUTPUT FROM CODE:

MY CODE:

<?xml version = "1.0" encoding = "uft-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Exercise 11.22</title>
    <script type = "text/javasript">
   
    function displayDate()
    {
    var myForm = document.getElementById("myForm");
    var month = parseInt
    (myForm.month.value)-1;
    var day = parseInt(myForm.day.value);
    var year = parseInt(myForm.year.value);
    var d = new Date(year, month, day);
    myForm.output.value =
    "d.toString(): " + d.toString()+
    " d.toLocaleString(): "+ d.toLocaleString()+
    " d.toUTCString(): "+ d.toUTCString();
    }
   
</script>
</head>
<body>

<form id = "myForm" action = "">
<table border = "0">

<tr><td>Enter month:</td>
<td><input name: "month" type = "text" /></td>

</tr>

<tr><td>Enter day:</td>
<td><input name = "day" type= "text" /></td>

</tr>

<tr><td>Enter year:</td>
<td><input name= "year" type= "text" /></td>

</tr>

<tr><td colspan = "2">
<input type = "button" value = "Display Date"
/>


</td>
</tr>
</table>

<div><textarea name = "output" rows = "4" cols = "50">
</textarea></div>

</form>

</body>
</html>

Explanation / Answer

the "getDate()" function does what you want it to do. Your won't need the form but will still need the button to call your function. function displayDate() { var date = getDate(); var d = new Date(date[2], date[0], date[1]); myForm.output.value = "d.toString(): " + d.toString()+ " d.toLocaleString(): "+ d.toLocaleString()+ " d.toUTCString(): "+ d.toUTCString(); } function getDate() { var date = new Array(parseInt("hi"),parseInt("hi"),parseInt("hi")), changingText, defaultValue = 1,upperVal = 12, lowerVal = 1, standardText = "Please enter ", errorText = "", i = 0; //date[0] is month, date[1] is date, date[2] is year. for(;i upperVal || date[i]