Computer problems,Computer help
*AX SOFT>>>Programming & Design

Palindrome Words in Javascript?


does someone just can help?
Palindrome
a palindrome is a word that can be read backwards
like "racecar" I just need something
that will let you enter a word then the program will display it bakwards then it'll say if it is a perfect palindrome like "racecar" or an ordinary palindrome.

thank you. .
please, if you don't have any idea with my question
don't post any messages like:
"Don't ask someone to do your homework"

please have respect. . .
thank you so much

<html>
<head>
<!--
No matter which you select
as "best answer" - pick one.
-->
<script>
function get(eid) {
var d = document;
var r = d.getElementById(eid);
return r;
}

function test() {
var p = get('pcand').value;
var r = reverse(p);
var isPal = p == r;
var msg = p +
' backwards is: ' + r;
get('rev').innerHTML = msg;
msg = p + ' is ' +
((isPal)?'':'NOT') +
' a palindrome';
get('msg').innerHTML = msg;
}

function reverse(s) {
var r = '';
var last = s.length;
for (var i = last; -1 < i; i--) {
r += s.charAt(i);
}
return r;
}
</script>
</head>
<body>
<form>
Enter word to test:
<input type="text" id="pcand" />
<input type="button"
value="test word"
onclick="test();" />
</form>
<div id="rev">聽</div>
<div id="msg">聽</div>
</body>
</html>

Assuming this isn't your homework and you can perhaps use another language, i.e. not Javascript then I think this will work in asp.

Set up a form which posts to this and then you can customise the results part but this is the core part which should work:


wordtocheck = request("wordtocheck")
WordLength = Len(wordtocheck)

For a = 1 To WordLength
聽聽聽look1 = Mid(wordtocheck , a, 1)
聽聽聽look2 = Right(wordtocheck , a)
聽聽聽look2 = Left(look2, 1)

聽聽聽聽聽聽If look1 <> look2 Then
聽聽聽聽聽聽聽聽聽response.write ("No")
聽聽聽聽聽聽聽聽聽response.end
聽聽聽聽聽聽End If

Next

response.write ("Yes")

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • I need to no a free website or program where i can edit photos? Like i want to make a photo into a puzl photo?

    The Gimp is a great image editing program! It's a lot like photoshop except $700 cheaper. It's a free program and you can download it straight from ...

  • How do you let users create there own web page in my page?

    the easiest way would be o use something like xoops: ...

  • What program can i use to create an animated GIF?

    UnFREEz 2.1 is a great program to use it very basic and easy to use but it gets strait to the point. ...

  • Web design and Graphic design?

    Ok. So My answer is a bit different from the other guys. I'm the director of training for an online creative training company (we train web design, graphic arts, marketing, Adobe Software etc)...

  • What is wrong with my c++ code?

    i'm a rookie, but are you sure there is supposed to be a ; (semicolen) ending line (b) ? isn't line (a) supposed to end in { for the statement on the next line? for(int y=0; y<Fi...

  • C++ tcp help?!?!?

    I tried compiling your code. I manage to compile it if I swap the include order of "Ws2tcpip.h" and "winsock2.h". Ie. #include "winsock2.h" #include "Ws2tcpi...

  • Help with embedding code in PHP?

    just keep writing the css you want in the fwrite() function. fwrite($pfile, "<embed src = \"$target_path\ /><p>" . '{font-size:x-small; font-weight:normal; back...

  • Charts in JAVA!?!?!?!?

    The latest - jre 6.0.2. Copy the ".jar" file into the JAVA/JRE/LIB/EXT. Then include the jar file in ur classpath. Then import it. O.K.?

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster