aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Java Script Reverse Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Java Script Reverse Program" Watch "Java Script Reverse Program" New topic
Author

Java Script Reverse Program

Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
Hi I am writing a code to reverse the numbers in a text box provided.
Also When i press the button it should disdplay the numbers in reverse orider:
Please assist as I am not able to display these numbers in revers order:
Here is my code:
function reverse1(windowform1)
{
str = document.windowform1.revtext.value;
for (i = 0; i <= str.length; i++)
text = str.substring(i, i+1) + text;
document.windowform1.revtext.value = text;
}



<INPUT TYPE="text" NAME="revtext" READONLY><BR><BR>
<INPUT TYPE="button" VALUE="REVERSE" onclick="reverse1(this.windowform1)">
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10113
    
165

for (i = 0; i <= str.length; i++)

If you want to reverse the contents of the string, then you will have to start from the other end. i.e.

[ August 18, 2006: Message edited by: jaikiran pai ]

[My Blog] [JavaRanch Journal]
Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
Hi Jaikiran,

Thanks for your immediate reply.
I tried your code the other end but it did not give me the desired result:

Can you help me further?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10113
    
165

I am not sure why it did not work for you, but here's what you have to do:

Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
Hi,

I tried your code but it isn't working for me???
Can you suggest me somethig else so that I can modify your code to get the desired result??

thanks in advance!!!
Brijesh Shah
Ranch Hand

Joined: Aug 08, 2006
Posts: 34
hey thanks
I managed to get the result...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Script Reverse Program