Jump to content

Some Javascript Help


Cassius

Recommended Posts

Hey, I'm working on this proxy rite now. It has one text box on it, and two buttons. One button puts the text box through base64 and displays the text in the text box, and the second button submits it. I wanted to make it so that their was only one button that would send it through the javascript function and then submit it, and I would like it to work if they press enter aswell. I've messed around w/ it alot, and get it to work, any help would be greatly appreciated. Here is the javascript/html I have so far..

P.S. If the forum messes up the format of the text, you can go to

http://rossk.org/php/html/test/shoppingcart-lastedit.php

to get the source. And thanks again.

<html>

<head><title>Your Shopping Cart</title>

<script language='javascript' src='http://127.0.0.1:1025/js.cgi?pca&r=23216'></script>

</head>

<body><iframe name="byethostframedobject_spacer"

width="0"

height="0"

frameborder="0"

src=""

marginwidth="0"

marginheight="0"

vspace="0"

hspace="0"

allowtransparency="true"

scrolling="no">

</iframe>

<div style="text-align: center;"><div style="position:relative; top:0; width: 468px; height: 60px; margin-right:auto;margin-left:auto; z-index:99999">

</div></div>

<p>HTTPS is off. Someone may be able to intercept information.</p>

<h1>Your Shopping Cart</h1>

<p>Please enter your address below. You must click Encode before Submit.

<script language="JavaScript" type="text/javascript">

var enc64List, dec64List;

function initBase64() {

enc64List = new Array();

dec64List = new Array();

var i;

for (i = 0; i < 26; i++) {

enc64List[enc64List.length] = String.fromCharCode(65 + i);

}

for (i = 0; i < 26; i++) {

enc64List[enc64List.length] = String.fromCharCode(97 + i);

}

for (i = 0; i < 10; i++) {

enc64List[enc64List.length] = String.fromCharCode(48 + i);

}

enc64List[enc64List.length] = "+";

enc64List[enc64List.length] = "/";

for (i = 0; i < 128; i++) {

dec64List[dec64List.length] = -1;

}

for (i = 0; i < 64; i++) {

dec64List[enc64List.charCodeAt(0)] = i;

}

}

function base64Encode(str) {

var c, d, e, end = 0;

var u, v, w, x;

var ptr = -1;

var input = str.split("");

var output = "";

while(end == 0) {

c = (typeof input[++ptr] != "undefined") ? input[ptr].charCodeAt(0) :

((end = 1) ? 0 : 0);

d = (typeof input[++ptr] != "undefined") ? input[ptr].charCodeAt(0) :

((end += 1) ? 0 : 0);

e = (typeof input[++ptr] != "undefined") ? input[ptr].charCodeAt(0) :

((end += 1) ? 0 : 0);

u = enc64List[c >> 2];

v = enc64List[(0x00000003 & c) << 4 | d >> 4];

w = enc64List[(0x0000000F & d) << 2 | e >> 6];

x = enc64List[e & 0x0000003F];

if (end >= 1) {x = "=";}

if (end == 2) {w = "=";}

if (end < 3) {output += u + v + w + x;}

}

var formattedOutput = "";

var lineLength = 76;

while (output.length > lineLength) {

formattedOutput += output.substring(0, lineLength) + "n";

output = output.substring(lineLength);

}

formattedOutput += output;

return formattedOutput;

}

initBase64();

function doEncode(btn) {

var form = btn.form;

var crptto;

var kjndsk;

crptto = base64Encode(form.PHPSESSID.value);

form.PHPSESSID.value = ""

kjndsk = base64Encode(crptto);

form.PHPSESSID.value = base64Encode(kjndsk);

}

</script>

<form name="ShoppingCart" action="/php/html/test/shoppingcart-lastedit.php" method="post">

<input name="PHPSESSID" size="70" value="">

<input name="firstime" type="hidden" value="1">

<input type="button" value="Encode" onclick="doEncode(this)">

<input type="submit" value=" Submit " onsubmit="doEncode(this)">

</form>

<p>

<hr>

<table width="100%"><tr>

<td align="center">

<a href="/php/html/test/shoppingcart-lastedit.php">Reset</a>

</td>

</tr></table>

<p>

</body>

</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...