why isnt this working????
I'm trying to make this array output ascii and hex values but it wont allow me to add % or &# or even ABCDEF behind the numbers, whats wrong with this script?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html>
<head>
<title></title>
<!--hex-->
<script type="text/javascript">
<!--
String.code = {a:61, b:62, c:63, d:64, e:65, f:66, g:67, h:68, i:69, j:6, k:6, l:6, m:6, n:6, o:6, p:70, q:71, r:72, s:73, t:74, u:75, v:76, w:77, x:78, y:79, z:7}
String.prototype.toCode = function () {
var a = this.split('');
for (j=0; j<a.length; j++) {if (String.code[a[j]]) a[j] = String.code[a[j]]}
return a.join('');
}
// -->
</script>
</head>
<body>
<form action="">
<div>
<p><label>Characters<br>
<textarea name="chars" rows="5" cols="20" onkeyup="this.form.codes.value = this.value.toCode()"></textarea></label></p>
<p><label>Codes<br>
<textarea name="codes" rows="5" cols="20"></textarea></label></p>
</div>
</form>
</body>
</html>
I am seriously confused this should not be happening right? If you know how to fix it so it can omit % and &# and even letters ABCDEF please add to it, and post it for me, I would seriously appreciate it, this is driving me CRAZY!!!
thanks
codeone
"The secret to creativity is knowing how to hide your sources."
- Einstein
code one posted this at 11:39 — 27th November 2003.
They have: 17 posts
Joined: Nov 2003
i worked it out.
co
Suzanne posted this at 16:41 — 27th November 2003.
She has: 5,507 posts
Joined: Feb 2000
did you want to explain what went wrong for the edification of others?
code one posted this at 17:35 — 27th November 2003.
They have: 17 posts
Joined: Nov 2003
sure I would love to clarify. Well what was happening was first I was using string.code, because this script was a transition from an old script I had which I programmed to write in binary, artistic reasons, don't ask, lol. anyway, I thoguht hey this is close to what I was looking for so why not use it, so I did, I inputted the hex values, and ran into a problem, the darn thing wouldnt allow me to use % or even letters, so I was verily confused, and what was going on. So I started asking around, referencing tutorials, and finally I had an answer and it came it three parts, one, string.code, doesn't omit % among anything else which is not a number, two, % is a javascript modular, or something, and the script thinks it's being told to do something, and three, I was using uppercase, to find lowercase letters, anyway, as badly explained as it is, in short it just didn't fly. So what I did was this, I added this string:
for (j=0; j<a.length; j++) {if (String.code[a[j]]) a[j] = '%' + String.code[a[j]]}
and that took care of the percent sign, so Im almost in buisness right? So now for the letters. So what I did was added this to the array, where needed:
j:6+'a'
and that took care of the letters.
so now it works just fine, and now I can finsih what I have been trying to finish for the past couple days.
hope that helps,
code one
P.s. the code isn't right protected, so use it how you wish, if you would like.
"The secret to creativity is knowing how to hide your sources."
- Einstein
code one posted this at 18:48 — 27th November 2003.
They have: 17 posts
Joined: Nov 2003
do you know any way to omit the ' and " marks I can't seem to get those to work now.
thanks ahead
code one
P.s. I read your page, so no pressure, no pressure. Please post when you feel like it.
"The secret to creativity is knowing how to hide your sources."
- Einstein
Suzanne posted this at 21:29 — 27th November 2003.
She has: 5,507 posts
Joined: Feb 2000
Entirely omit or render them neutral?
Eh, I'm always grumpy, don't pay any attention to declarations of grumpiness.
I think that one of the JavaScript gurus would be able to work it through with you. What is the purpose of your script?
code one posted this at 07:31 — 28th November 2003.
They have: 17 posts
Joined: Nov 2003
you know what I think I have been choosing the wrong word this whole time, lol, I shouldn't say omit, I should say allow, lol. What I meant was is there a way to allow for the ' and " to be placed in the array, along with a: b: c: etc. so when I key either " or ' it would output %22 and %20, just like if I key a it outputs %65.
sorry to confuse you with the wrong word,
code one
p.s. haha grumpys good.
"The secret to creativity is knowing how to hide your sources."
- Einstein
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.