Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Ajax not storing spaces from inputs using $f()

    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".?!?
    Code:
    <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
    Code:
    <!--#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
    Code:
    <!--#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

  • #2
    New Coder
    Join Date
    Nov 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    forgot to mention i am using an oracle database if that is an issue with it

  • #3
    New Coder
    Join Date
    Nov 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    	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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •