...

View Full Version : Ajax not storing spaces from inputs using $f()



mull300
08-10-2006, 03:32 PM
Ok so i am trying to set up a simple form that you can add comments that when you submit the comments it adds the comments to the database and then pulls the comments from the database. The problem is that when i submit the data the results show without the spaces. "This is a test" comes out like this "Thisisatest".?!?


<script src="prototype.js" ></script>
<script>
function newComment()
{
var comment = $F('comment');
var subject= $F('subject');
var url = 'process_insert.asp';
var pars = 'comm=' + comment + '&sub=' + subject;
var myAjax = new Ajax.Request(
url,
{
method: 'post',
parameters: pars,
onComplete: showComments
});

}
function showComments(originalRequest)
{
var url = 'process_insert2.asp';
var pars = 'last_comment='+originalRequest.responseText;
var myAjax = new Ajax.Updater( 'existing_comments', url, { method: 'post', parameters: pars });
}
</script>

</head>

<body>
<div>
<form name="test" >
<input type="text" id="subject" size="20" /><br/>
<textarea id="comment" cols="30" rows="8"></textarea>
<input type="button" onClick="newComment()" value="Test"/>
</form>
<br>
<br><br>

<div id="existing_comments"></div>



process_insert.asp

<!--#include file="classes/global.asp"-->
<!--#include file="classes/functions.asp"-->
<!--#include file="var/session_variables.asp" -->
<%
comments=Request.form("comm")
subject=Request.form("sub")
call insert_ora("comments","id,case_number,type,comments,subject","1,97,'customer','"&comments&"','"&subject&"'")
%>

process_insert2.asp


<!--#include file="classes/global.asp"-->
<!--#include file="classes/functions.asp"-->
<!--#include file="var/session_variables.asp" -->
<html>
<body>
<%
response.write(Request.form("last_comment"))
call select_ora("*","comments","ORDER BY id ASC")
Do While Not ora_select.EOF
%>
<div><% Response.Write(ora_select("subject")) %></div>
<div><% Response.Write(ora_select("comments")) %></div>
<%
ora_select.moveNext
Loop
ora_select.close
%>
Hello

</body>
</html>


Can someone help this is my first time using ajax

mull300
08-10-2006, 04:37 PM
forgot to mention i am using an oracle database if that is an issue with it

mull300
08-10-2006, 08:57 PM
var myAjax = new Ajax.Request(
url,
{
method: 'post',
parameters: pars,
onComplete: showComments
});


there it is i guess using 'post' instead of 'get' is the problem. for somereason it didnt like that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum