views:

133

answers:

3

hi , Below is my html

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script type="text/javascript">
function Data_Check()
{
var xmlHttp;

try
  {  
  xmlHttp=new XMLHttpRequest();  }
catch (e)
  { 
   try
    {    
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
     }
  catch (e)
    {   
     try
      {     
       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");   
          }
    catch (e)
      {      
      alert("Your browser does not support AJAX!");      
      return false; 
           }    
           } 
            }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      alert(xmlHttp.responseText);
      }
    }   

    var RES = document.getElementById("Remarks").innerHTML;
    var params ="RES="+RES;
    xmlHttp.open("POST","Data_Check.asp",true);       
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);

   }
</script>
</head>

<body>
<textarea id="Remarks" rows="5" name="Remarks" cols="79" style="font-family: Arial; font-size: 11px">please, accept my submit form.</textarea>

<br>
<img id="Submit" onclick ="return Data_Check();" border="0" src="submit.png" width="145" height="28">
</body>
<img
</html>

Here i facing the problem is,

When i submit "Remarks" textarea innerhtml to my "Data_Check.asp"

<%
RES = Request.Form("RES")
%>

and this remarks save in my sql database.( database field is "Remarks_text" and datatype is "text")

In the data base textarea data is read ("please, accept my submit form.") textarea data with out space.

like this please,acceptmysubmitform.

I need to save please, accept my submit form.

hoping your support

A: 

Change

document.getElementById("Remarks").innerHTML;

to

document.getElementById("Remarks").value;

Pentium10
+4  A: 

Try url encoding:

var RES = encodeURIComponent(document.getElementById("Remarks").value);
Darin Dimitrov
A: 

I suspect spaces are not supported in URLs or HTTP headers, hence old URLs had %20 instead of a space. Modern browsers and servers now do this behind the scenes.

I found replacing spaces with %20 (formValues = formValues.replace(/ /gi,"%20"); prior to sending solved the problem.

Gordon