Slip 9
Write a java script program to accept a string and
check whether the input string is palindrome string or not
</html>
<html>
<head>
<script>
function
myFunction()
{
//get the value
from textbox
var str =
document.getElementById('txtbox').value;
//call
checkPalindrome() and pass str
var result =
checkPalindrome(str);
alert('The
Entered String "'+str +'" is "'+result+'"');
}
function
checkPalindrome(str)
{
var orignalStr;
//lowercase the
string
str =
str.toLowerCase();
//store the str
in orignalStr for future use
orignalStr =
str;
//reverse the
entered string
str =
str.split(''); //split the entered string
str =
str.reverse(); //reverse the order
str =
str.join(''); //then join the reverse order array values
var reverseStr
= str;
//finally check
both the Original string stored in orignalStr
//and reversed
to find the palindrom
if(orignalStr
== reverseStr){
return
'Palindrome'; // return "Palindrome" if true
}else{
return 'Not
Palindrome';
}
}
</script>
</head>
<body>
<form
action="" method="get">
<input
type="text" id="txtbox" placeholder="Enter
String" />
<input
type="button" onclick="myFunction()" value="Check
Palindrome" />
</form>
</body>
Write the HTML code which generates the following
output.(use internal CSS to format the table)
<html>
<head>
<style>
body
{
background-image: url("1.jpg");
}
</head>
<head>
<style>
body
{
background-image: url("1.jpg");
}
</head>
<body>
<table border=1>
<tr>
<th>Country</th>
<th
colspan="2"">Population</th>
</tr>
<tr>
<td
rowspan="3">India</td>
<td>1998</td>
<td>85</td>
</tr>
<tr>
<td>1999</td>
<td>90</td>
</tr>
<td>2000</td>
<td>100</td>
</tr>
<tr>
<td
rowspan="3">USA</td>
<td>1998</td>
<td>85</td>
</tr>
<tr>
<td>1999</td>
<td>90</td>
</tr>
<td>2000</td>
<td>100</td>
</tr>
</table>
</body>
</html>