how to solve the problems????
<HTML>
<HEAD>
<TITLE>loop</TITLE>
<script language=javascript>
document.write("<form>");
for(i=1;i<=10;i )
{
document.write("<input type=text value=" i "><br><br>");
}
document.write("</form>");
</script>
<SCRIPT Language="JavaScript">
rows = 21
columns = 21
str = ""
str = '<table border="1" cellspacing="1" cellpadding="5">'
for(i = 1; i < rows; i )
{
str = '<tr>'
for (j = 1; j < columns; j )
{
str = '<td>' (i * j) '</td>'
}
str = '</tr>'
}
str = '</table>'
document.write(str)
document.write('<br>');
</SCRIPT>
<SCRIPT Language="JavaScript">
for(i=1;i<7;i )
{
for(j=1;j<=i;j )
{
document.write(j);
}
document.write('<br>');
}
document.write('<br>');
</SCRIPT>
<SCRIPT Language="JavaScript">
for(i=6;i>=1;i--)
{
for(j=1;j<=i;j )
{
document.write(j);
}
document.write('<br>');
}
document.write('<br>')
</SCRIPT>
<script language="javascript">
function calculate(){
marks= document.frmOne.marks.value
switch (marks) {
case "1":
alert("You have got A Grade")
break
case "2":
alert("You have got B Grade")
break
case "3":
alert("You have got C Grade")
break
case "4":
alert("You have got D Grade")
break
case "5":
alert("You have got F Grade")
break
case "6":
alert("You have got G Grade")
break
default:
alert("undetermined")
}
}
</script>
<script language=javascript>
function day(d){
switch (d){
case 'sunday':window.location='http://www.google.com';
break;
case 'monday':window.location='http://www.yahoo.com';
break;
case 'tuesday':window.location='http://www.microsoft.com';
break;
case 'wednesday':window.location='http://www.google.com';
break;
case 'thursday':window.location='http://www.yahoo.com';
break;
case 'friday':window.location='http://www.microsoft.com';
break;
case 'saturday':window.location='http://www.google.com';
break;
default:break;
}
}
</script>
<script language="javascript">
function message(){
day= document.frmtwo.day.value
switch (day) {
case "1":
alert("You will have a great day");
break
case "2":
alert("You are winner");
break
case "3":
alert("Having Fun Today");
break
case "4":
alert("You Will Face Some Problem");
break
case "5":
alert("Today is your best day");
break
case "6":
alert("Party Time");
break
case "7":
alert("Masti Time");
break
default:
alert("undetermined");
}
}
</script>
<script language="JavaScript">
function getDate() {
var today = new Date();
var date = today.getDate();
if (date == 1) suffix = ("st");
else if (date == 2) suffix = ("nd");
else if (date == 3) suffix = ("rd");
else if (date == 21) suffix = ("st");
else if (date == 22) suffix = ("nd");
else if (date == 23) suffix = ("rd");
else if (date == 31) suffix = ("st");
else suffix = ("th");
document.frmMain.txtDay.value = date suffix;
var month = today.getMonth();
if (month == 1) monthName = "January";
else if (month == 2) monthName = "February";
else if (month == 3) monthName = "March";
else if (month == 4) monthName = "April";
else if (month == 5) monthName = "May";
else if (month == 6) monthName = "June";
else if (month == 7) monthName = "July";
else if (month == 8) monthName = "August";
else if (month == 9) monthName = "September";
else if (month == 10) monthName = "October";
else if (month == 11) monthName = "November";
else if (month == 12) monthName = "December";
else monthName = ("Enter Correct Month");
document.frmMain.txtMonth.value = monthName;
document.frmMain.txtYear.value = today.getFullYear();
}
</script>
<script language="JavaScript" type="text/javascript">
var A = prompt("Enter a number", "Enter The Number");
alert("You Have Entered " A "");
for(i=1; i<=100; i )
{
document.write(i);
if( i == A)
{
alert("loop breaked");
break;
}
}
</script>
<br>
<script language="JavaScript" type="text/javascript">
var B = prompt("Enter Number");
i=1;
while(i<=20)
{
if(i==B)
{
alert(i);
break;
}
i ;
}
</script>
<br>
<BODY bgcolor="lightgreen">
<a href=# onClick="day('sunday')" >sunday</a><br>
<a href=# onClick="day('monday')" >monday</a><br>
<a href=# onClick="day('tuesday')" >tuesday</a><br>
<a href=# onClick="day('wednesday')" >wednesday</a><br>
<a href=# onClick="day('thursday')" >thursday</a><br>
<a href=# onClick="day('friday')" >friday</a><br>
<a href=# onClick="day('saturday')" >saturday</a><br><br><br>
<FORM NAME = frmOne>
Select your marks range :
<select name = marks>
<option value = 1>90 to 100</option>
<option value = 2>80 to 90</option>
<option value = 3>70 to 80</option>
<option value = 4>60 to 70</option>
<option value = 5>50 to 60</option>
<option value = 6>less than 50</option>
</select>
<input type=button value="grade" onClick=calculate()>
</form>
<FORM NAME = frmtwo>
Select Day Of The Week :
<select name = day>
<option value = 1>Sunday</option>
<option value = 2>Monday</option>
<option value = 3>Tuesday</option>
<option value = 4>Wednesday</option>
<option value = 5>Thursday</option>
<option value = 6>Friday</option>
<option value = 7>Saturday</option>
</select>
<input type=button value="Message" onClick=message()>
</form>
<form name="frmMain" id="frmMain" action="javascript:getDate();"> Today is the <input type="text" id="txtDay" name="txtDay" value="" /> of
<input type="text" id="txtMonth" name="txtMonth" value="" />,
<input type="text" id="txtYear" name="txtYear" value="" />.
<input type="submit" value="Get Date"/>
</form>
</HEAD>
</BODY>
</HTML>
Please reply me with examples to the solutions..
2nd question using while loop not answered.
- 3rd question is not working. U have to prompt if the number is correct. no checking done.
- 4th question unanswered.
- redirection is not working with 7th question.
- solution for 10th question is not working.