In: Computer Science
5. Create an HTML file that uses an array to store links for your three favorite websites. Use a for loop to display each link URL within an alert dialog box. I would like to see the HTML page displaying the message.
SOLUTION-
Below is HTML file code :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Websites</title>
<script>
function display()
{
var websites= new Array();
var i =0;
websites[0]=
document.getElementById("TS1").value;
websites[1]=
document.getElementById("TS2").value;
websites[2]=
document.getElementById("TS3").value;
for(i =0 ;i<3;i++){
alert(" The website "+ (i+1) +" is " +websites[i]);
}
}
</script>
</head>
<body>
<table>
<tr>
<td>Website #
1</td>
<td><input
type="text" name="TS1" id="TS1"></td>
</tr>
<tr>
<td>Website #
2</td>
<td><input
type="text" name="TS2" id="TS2"></td>
</tr>
<tr>
<td>Website #3
</td>
<td><input
type="text" name="FS1" id="TS3"></td>
</tr>
<tr>
<td colspan="2"
align="right"><input type="submit" value="Display Website"
onclick="display()"></td>
</tr>
</table>
</body>
</html>
Sample Output:
First Page:
After clicking on Display Button
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL
SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------