calls an ajax routine and passes that value to a php page and then takes back the response ,i have done it all but now i was trying to encrypt the information or the string or the value that is passed through the drop down menu and concatinated with the url and passed to that page and then on that page it would call the js function in php and pass that encoded string to an another decoding Javascript function and takes back the decoded string then run the query for the desired values and then response back but i am not doing it right i am pasting only the relevent js and php code here ,thanks for any help in advance.
function Pupu(val) is called onchange and passes the value to the getflds.php page,and function xor_str(url) id the encoding function that encodes the string
MAIN PAGE.PHP
Expand|Select|Wrap|Line Numbers
- function xor_str(url){
- //var to_enc = document.forms['the_form'].elements["str"].value;
- var to_enc = url;
- //var xor_key=document.forms['the_form'].elements.xor_key.value
- var xor_key=6;
- var the_res="";//the result will be here
- for(i=0;i<to_enc.length;++i){
- the_res+=String.fromCharCode(xor_key^to_enc.charCodeAt(i));
- }
- //document.forms['the_form'].elements.res.value=the_res;
- return the_res;
- }
- function Pupu(val){
- if(val!="" && val!="none"){
- var fobj=document.forms['Selfrm'];
- var valar=val.split("|");
- var cat_id=valar[0];
- var prd_id=valar[1];
- var rows=valar[2];
- //alert(prd_id);
- var prd_name=fobj.elements['prod'+rows].options[fobj.elements['prod'+rows].selectedIndex].text;
- prd_name=stripper(prd_name);
- var url="getflds.php?";
- var cnct_str="cat_id="+cat_id+"&prd_id="+prd_id+"&prd_name="+prd_name+"&rows="+rows;
- var dec_str=xor_str(cnct_str);
- alert(dec_str);
- var enc_str=decrypt_str(dec_str);
- alert(enc_str);
- return;
- url=url+"str="+dec_str;
- //alert(url);
- //return;
- xmlHttp=GetXmlHttpObject();
- if(xmlHttp==null){
- alert("Please Upgrade your browser to continue");
- }else{
- xmlHttp.onreadystatechange=stateFlds;
- xmlHttp.open("GET",url,true);
- xmlHttp.send(null);
- }
- }
- }
- function stateFlds(){
- if(xmlHttp.readyState==4){
- if(xmlHttp.status==200){
- alert(xmlHttp.responseText);
- //var a=xmlHttp.responseText;
- //var pipe=a.split("^");
- //var tab=pipe[0];
- //var rows=pipe[1];
- //alert(tab);
- //document.getElementById('specs'+rows).innerHTML=tab;
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- <?
- $str=$_GET['str'];
- echo $str;
- echo "<script type='text/javascript' language='javascript'>decrypt_str(".$str.");</script>";
- ?>
- <script type="text/javascript" language="javascript">
- function decrypt_str(){
- alert("hi");
- var to_dec=<?php echo $str;?>;
- var dec_str;
- document.forms['the_form'].elements.dec_res.value="";
- var xor_key=6;
- for(i=0;i<to_dec.length;i++){
- dec_str+=String.fromCharCode(xor_key^to_dec.charCodeAt(i));
- }
- document.write(dec_str);
- }
- </script>
OMER ASLAM