User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,006 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,395 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1030 | Replies: 2
Reply
Join Date: Mar 2007
Posts: 3
Reputation: marylove2007 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
marylove2007 marylove2007 is offline Offline
Newbie Poster

Please Help in JavaScript Problem

  #1  
Mar 1st, 2007
Help Plzzzz!!!!!!!!!!!!!!!!!!!...
> A palindrome is a number or a text phrase that reads the same backward and forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611.
> ,mvcxmzxWrite a script that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long or is not a valid number, output XHTML text that displays an
> alert dialog indicating the problem to the user. Allow the user to enter a new value after dismissing the alert dialog. Continue the whole process until the user enters “stop”.
var startNumber = parseInt(12345/10000)
var endNumber = 12345%10
var remainNumber = parseIn((12345-startNumber*10000)/10)
> This is not a Homework at all.
> plzz in Java script.
> Hellllllllllllllllllllllllllllp
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 1,289
Reputation: vishesh is on a distinguished road 
Rep Power: 4
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: Please Help in JavaScript Problem

  #2  
Mar 1st, 2007
Originally Posted by marylove2007 View Post
This is not a Homework at all.
.....but it seems to be....not real life problems!!!

Post whatever you have done till now...and we'll help you. Solving all these would would be like completing your homework even if isn't.
Last edited by vishesh : Mar 1st, 2007 at 3:06 am.
Reply With Quote  
Join Date: Mar 2007
Posts: 3
Reputation: marylove2007 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
marylove2007 marylove2007 is offline Offline
Newbie Poster

Re: Please Help in JavaScript Problem

  #3  
Mar 1st, 2007
Dear all

how to do it using Script Prompt, saying Enter a 5-digit integer or "stop" to stop the program
and in Html page

I want to put the number + is a palindrome and if user start with (0) like (01210) then Alert box say 01210 is not vald please enter a 5-digit number (not starting with 0) or "stop" to stop

Here is what I did so far but I failed to get to the above result

<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script type = "text/javascript">




function testNumber(errMsg) {

var trgtVal = /^\d{5}$/;
var promptMsg = (errMsg == 'error') ? 'Error!\nEnter a 5-digit integer or \'stop\' to stop the program' : 'Enter a 5-digit integer or \'stop\' to stop the program';

var reply = prompt(promptMsg,'')

var is5digitNo = (reply.search(trgtVal) != -1);
var is1sameas5 = (reply.charAt(0) == reply.charAt(4));
var is2is1sameas4 = (reply.charAt(1) == reply.charAt(3));

if (is1sameas5 && is2is1sameas4 && is5digitNo) {
alert(is1sameas5 && is2is1sameas4 && is5digitNo);
} else if (reply == 'stop') {
alert('Test stopped');
} else {
testNumber('error');
}

}



window.onload = testNumber;


</script>
</head>
<body>

<p>Click Refresh (or Reload) to run the script again</p>

</body>
</html>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:31 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC