HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old April 16th, 2008, 07:53 PM
ChiefOfGxBxL ChiefOfGxBxL is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 ChiefOfGxBxL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 27 sec
Reputation Power: 0
Exclamation JavaScript - Convert JAVASCRIPT Simple; Help!!

I want help with a program with JAVASCRIPT in an HTML window. I was thinking of something like this....
-----

[ BOX 1 ] [Output BOX 1]

-----

Lets say, that in BOX 1, you put the letter 'H'. It would then put in the outbox, the letter 'G' or something....so it takes the first letter, and converts it to another.

It takes a letter / number and converts it to another preset letter / number. Was planning on a secret chat language or something...maybe could incorporate it into my flash games too.

Thank you for all your help and suggestions! I am new to this website, so thank you very much for your time! My idea is that it would be able to be put into an HTML window. I know HTML very well too. Have no idea about JS, but have been to w3schools.com.


Reply With Quote
  #2  
Old April 18th, 2008, 05:35 AM
Galanodel's Avatar
Galanodel Galanodel is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Location: Athens, Greece
Posts: 40 Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 14 h 53 m 46 sec
Reputation Power: 36
Hallo & welcome!!!

There are a lot of algorithms that perform such tranformations. Unfortunatelly I cannot send any link as I read all of them in books only, but I bet u'll find numerus in the inet.

I will show u an example of how u can do this, but it is just one way that can be done......, there are inoumerous things like that, that u can think yourshelf, & a lot more u can find. I hope sb else may have suitable links for u.

Here is the working example:

Code:
<html>
	<head>
<Script language="javascript" >
		function startEncoding(str) {
			document.getElementById("outoutStr").value = encodeTxt(str);
		}
		
		function encodeTxt(str) {
			var tmp = -1;
			var codedPhr = "";	
			var codePhrase = "PutYourCodePhraseHereAndMakeSureItWillBeLargerInLe  ngthThanAnyPossibleLengthOfPhraseThatSTRwillHold";	
			for (var i=0; i<str.length; i++) {
				tmp = codePhrase.charCodeAt(i) + str.charCodeAt(i);
				if (parseInt(tmp) > 128) {
					tmp = (tmp - 128);
				}
				codedPhr += String.fromCharCode(tmp);
			}
			return codedPhr;
		}
		
		function startDecoding(str) {
			document.getElementById("originalStr").value = decodeTxt(str);
		}
		
		function decodeTxt(str) {
			var tmp = -1;
			var codedPhr = "";	
			var codePhrase = "PutYourCodePhraseHereAndMakeSureItWillBeLargerInLe  ngthThanAnyPossibleLengthOfPhraseThatSTRwillHold";	
			for (var i=0; i<str.length; i++) {
				tmp = str.charCodeAt(i) - codePhrase.charCodeAt(i);
				if (parseInt(tmp) < 0) {
					tmp = (tmp + 128);
				}
				codedPhr += String.fromCharCode(tmp);
			}
			return codedPhr;
		}
</Script>
</head>
	<body>
	My input uncoded Phrase:</br>
		<input type="text" name="inputStr" id="inputStr" value="" size="120"><br>
		<input type="button" name="btnConvert" id="btnConvert" value="Convert" onClick="javascript: startEncoding(document.getElementById('inputStr').  value);"></br>
		Here I can see the character transformation of the phrase I just wrote:</br>
		<input type="text" name="outoutStr" id="outoutStr" value="" size="120"></br>
		<input type="button" name="btnConvert" id="btnConvert" value="Convert Back" onClick="javascript: startDecoding(document.getElementById('outoutStr')  .value);" ></br>
		And finally, the initial phrase decoded again:</br>
		<input type="text" name="originalStr" id="originalStr" value="" size="120">
	 
	</body>
</html>


Good Luck!

Reply With Quote
  #3  
Old April 28th, 2008, 03:47 PM
ChiefOfGxBxL ChiefOfGxBxL is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 ChiefOfGxBxL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 27 sec
Reputation Power: 0
I like the code, but I do not understand how it works. I did use it and put it in an HTML. I do NOT need explaining, but would also like if you could help further...

Is there a way to make a key, such as...[var]
a=z
b=a
c=h
t=u

etc....
There is no pattern to that however. Those are just examples...

But thanks for helping. You rule :-O

Reply With Quote
  #4  
Old April 29th, 2008, 09:10 AM
Galanodel's Avatar
Galanodel Galanodel is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Location: Athens, Greece
Posts: 40 Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level)Galanodel User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 14 h 53 m 46 sec
Reputation Power: 36
1. U could create a double array,
e.g.: var my2Darr = [["a", "z"], ["b", "a"], ["c", "h"], ["d", "t"], ["e", "6"], ["f", "#"], ["t", "u"]];
where in ["a", "z"] "a" is the letter to be replaced by the "z"
in ["b", "a"] "b" is the letter to be replaced by the "a" e.t.c.
Then loop through the given phrase & replace the letters one by one.

2. U can do it hard coded, looping through the given phrase & using 26 (the No of the characters) switch cases....(too much to write but straight forward)

3. U can use two single arrays & switch the letters according to their possition in the array...
Or a single array & use a pattern on the possition...

It is exactly the same idea (difference is only in coding).

I would also propose u to try to anderstand the code i sent u before what it does, since u liked it...., because it is pretty close to what u ask...

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > JavaScript - Convert JAVASCRIPT Simple; Help!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway