Web Technology Slip 9

 Q1. Write a java script program to accept a string and check whether the input string is palindrome string or not .

Answer : 

<html>
<head>
<script>
function myFunction()
{
var str = document.getElementById('txtbox').value;
var result = checkPalindrome(str);
alert('The Entered String "'+str +'" is "'+result+'"');
}
function checkPalindrome(str)
{
var orignalStr;

str = str.toLowerCase();
orignalStr = str;
str = str.split(''); 
str = str.reverse(); 
str = str.join(''); 
var reverseStr = str;
if(orignalStr == reverseStr){
return 'Palindrome'; 
}else{
return 'Not Palindrome';
}
}
</script>
</head>
<body>
<form >
<input type="text" id="txtbox" placeholder="Enter String" />
<input type="button" onclick="myFunction()" value="Check Palindrome" />
</form>
</body>
</html>

Q2. Write the HTML code which generates the following output.(use internal CSS to format the table.



Answer : 

<!DOCTYPE html>
<html>
<title>assignment3</title>
<body>
 <table width="40%" align="left" cellpadding="1" cellspacing="5"  border="1">
 <tr>
    <td>Country</td>
    <td colspan="2">Population(in Crores)</td>
 </tr>

 <tr>
   <td rowspan="3">INDIA</td>
    <td>1998</td>
    <td>85</td> 
  </tr>

  <tr>
    <td>1999</td>
    <td>90</td> 
  </tr>

  <tr>
    <td>2000</td>
    <td>100</td>  
  </tr>

<tr>
   <td rowspan="3">USA</td>
    <td>1998</td>
    <td>30</td> 
  </tr>

  <tr>
    <td>1999</td>
    <td>35</td> 
  </tr> 

  <tr>
    <td>2000</td>
    <td>40</td>  
  </tr>

<tr>
   <td rowspan="3">UK</td>
    <td>1998</td>
    <td>25</td> 
  </tr>

  <tr>
    <td>1999</td>
    <td>30</td> 
  </tr> 

  <tr>
    <td>2000</td>
    <td>35</td>  
  </tr>
  
</table> 
</body>
</html>

Web Technology Slip 9 Web Technology Slip 9 Reviewed by technical_saurabh on December 21, 2020 Rating: 5

No comments:

Powered by Blogger.