Transfer of Javasript variables to php page

I know I am pestering you but I am being helpless for that… Really appreciate your efforts in this…

The code below is not working :frowning:

<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<title></title>
<script type=“text/javascript”>

function sendForm() {
var formO = document.getElementById(“frm1”);
//reset the textbox values to the encrypted values
var newval1 = encryptStr(document.getElementById(“value1”).value);
var newval2 = encryptStr(document.getElementById(“value2”).value);
window.alert(newval1);

//now submit the form
formO.submit();

}

function encryptStr(str) {
//put your encryption code here

var strOut = str + abc; // sample Encryption code
return strOut;

*/

}

</script>

</head>
<body>
<form id=“frm1” action=“myPhpScript.php” method=“post”>
First name: <input type=“text” name = “value1” id=“value1” value = “”/><br />
Last name: <input type=“text” name = “value2” id=“value2” value = “”/>
<input type = “button” value = “Submit” onclick=“sendForm();” />
</form>
</body>
</html>

That’s ok - the bill’s in the mail :smiley:
(just kiddin’)

This now works.

But bear in mind, for the php script to receive the encrypted strings you will have to reset the textbox values in the form to the respective encrypted strings (newval1, newval2) before .submit() as in my previous code.

 
<script type="text/javascript">
 
function sendForm() {
var formO = document.getElementById("frm1");
//reset the textbox values to the encrypted values
var newval1 = encryptStr(document.getElementById("value1").value);
var newval2 = encryptStr(document.getElementById("value2").value);
window.alert(newval1);
 
//now submit the form
//formO.submit();  [COLOR=red]//comment out for testing purposes
[/COLOR]}
 
function encryptStr(str) {
//put your encryption code here
var strOut = str + [B][COLOR=red]'[/COLOR][/B]abc[B][COLOR=red]'[/COLOR][/B]; // sample Encryption code
return strOut;
}
</script>

Thanks a lot guys… Your suggestions have helped me do this…

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<script language=“JavaScript” type=“text/javascript”>
function xor_str()
{

var formO = document.getElementById("the_form");
var username_val = document.forms['the_form'].elements["username"].value;
var password_val = document.forms['the_form'].elements["password"].value;
var xor_key='1234';
var username_res="";
var password_res=""
for(i=0;i&lt;username_val.length;++i)
{
       username_res+=String.fromCharCode(xor_key^username_val.charCodeAt(i));
}
for(i=0;i&lt;password_val.length;++i)
{
	password_res+=String.fromCharCode(xor_key^password_val.charCodeAt(i));
}
// XOR is done

//shifting the username_res to the left by 1 bit
//username_res = username_res &lt;&lt; 1;
//shifting the password_res to the left by 1 bit
//password_res = password_res &lt;&lt; 1;

//setting the xor'ed  and shifted value for submission
document.forms['the_form'].elements["username"].value = username_res;
document.forms['the_form'].elements["password"].value = password_res;
//alert("UserName: " + username_res);
//alert("Password: "+ password_res);
form0.submit();

}
</script>
</head>

<body>
<form name=“the_form” action=“transfer.php” method = “post”>
<table>
<tr><td colspan=“3”>Username:<input type=“text” name=“username”></td></tr>
<tr><td>Password: <input type=“text” name=“password”></td><td colspan=“2”><input type=“button” onClick=“xor_str()” value=“Submit”></td></tr>
</table>
</form>
</body>
</html>

I hope this is right. I am able to encrypt… Can you check once? Really appreciate the help again…