phpmady Posted May 31, 2010 Share Posted May 31, 2010 Hi, I am trying to update the textbox value onblur function calling, previously i used windows 1256 charset, now i have changed to utf-8, after that my update not working properly, am geting squares instead of values after update has been made this is my text box js calling <span class="view_col1"> <input type="text" onblur="namechange(this.value,'Articles_Title',{Articles_ID},'Articles_ID','articles')" value="{Articles_Title}"> </span> js file // JavaScript Document var xmlhttp; //function namechange(name_fieldvalue) function namechange(name_fieldvalue,name_fieldname,id_val,id_fieldname,table_name) { /* alert(name_fieldvalue); alert(name_fieldname); alert(id_val); alert(id_fieldname); alert(table_name); */ if (name_fieldvalue.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url="ajax_namechange.php"; url=url+"?name_fieldvalue="+name_fieldvalue; url=url+"&name_fieldname="+name_fieldname; url=url+"&id_val="+id_val; url=url+"&id_fieldname="+id_fieldname; url=url+"&table_name="+table_name; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } php file for update <?php include("global.php"); $name_fieldvalue=$_GET["name_fieldvalue"]; $name_fieldname=$_GET["name_fieldname"]; $id_val = $_GET["id_val"]; $id_fieldname = $_GET["id_fieldname"]; $table_name = $_GET["table_name"]; $sq = "UPDATE $table_name SET $name_fieldname='".$name_fieldvalue."' WHERE $id_fieldname = '".$id_val."'"; echo $sq; $DB_site->query($sq); $response = "done1"; //output the response echo $response; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.