danielagaba 0 Junior Poster in Training

hi

I'm using the following javascript code to generate an sql statement using field values. My problem is I want to encode the value of the field password using base64 encode

function changereadonly(field){
	var sql = "UPDATE%20user%20SET%20"
	if(field['button'].value=='SAVE'){

	for (i = 0; i < field.length; i++) {
		if ((field.elements[i].name != 'userID' )  && ( (field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s"))) {
			if((field.elements[i].name == 'username' || field.elements[i].name == 'password') && field.elements[i].value=="")
			{
				alert('Please complete all required fields - Password or Username');
				return false;
			}
			if(field.elements[i].value!=""){
				sql = sql + field.elements[i].name + "='" + field.elements[i].value + "', "
			}
    		}
	}
	document.getElementById("cancelbutton").innerHTML=""
	sql = "functions/run_sql.php?sql=" +sql + "active=1%20where%20userID='" + field['userID'].value + "'"
	field['button'].value='Edit Profile';
	savedetails(sql.replace(/ /g,"%20").replace(/"'"/g,"%27"));
	}else{
		field['button'].value='SAVE';
		document.getElementById("cancelbutton").innerHTML="<input class=back type=reset value=Cancel name=cancelbutton onclick=canceledit()>"
	}

	for (i = 0; i < field.length; i++) {
    		if ((field.elements[i].name != 'userID' )  && ( (field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s"))) {
			field.elements[i].disabled=!field.elements[i].disabled;
      		}
    	}
}