Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ajax edit-in-place w/ prototype.js

Status
Not open for further replies.

tamak

Programmer
Sep 6, 2006
19
US
(Dont blast me - I usually frequent this forum, but originally posted in the AJAX discussion forum but was directed here)

re:
Ive been studying this tutorial / example and am trying to get it to work (i.e. 'catch' the edited text (textarea) at the 'save_URL' to then be able to do something with it like writ it to a database, etc. -- for now I'd be happy if I could just response.write it out and have it displayed)...

... but when I try to access the text that is supposed to be 'passed' to the subsequent page using any of the following, the string is empty:

Code:
request.form("bigedit")
request.querystring("bigedit")
request.querystring


... in PHP I understand its as simple as

Code:
$the_name = htmlspecialchars($_GET['greeting-name']);


how can I 'retrieve' / access the content using vb / asp?
 
heres the code for the page where the user edits the content (just click on the text that reads "Multi row editor: Lorum ipsum lorum ..."

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
  <title>script.aculo.us Demo</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="scriptaculous/lib/prototype.js" type="text/javascript"></script>
  <script src="scriptaculous/src/scriptaculous.js" type="text/javascript"></script>
  <script src="scriptaculous/src/unittest.js" type="text/javascript"></script>
  <style type="text/css" media="screen">
    .inplaceeditor-saving { background: url(wait.gif) bottom right no-repeat; }
  </style>
</head>
<body>
<h1>script.aculo.us Demo</h1>
<p>
  Demo of the Ajax.InPlaceEditor.
</p>



<p id="tobeedited3">Multi row editor: Lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum lorum ipsum</p>
<script>
new Ajax.InPlaceEditor($('tobeedited3'), 'test_add.asp', { rows:5, ajaxOptions: {method: 'post'} //override so we can use a static for the result
    });

</script>
</body>
</html>


Heres the page that the edited test is passed to (this page should just retrieve the edited content (this content may be simply a word or date OR Im hoping it could also be a large portion of text (paragraphs)). The data captured from the field is then assigned a variable name and written to a simple access database (the db write works fine, but no variable is retrieved at all)

Code:
<%@ Language="VBScript" %>
<% Option Explicit %> 
<html>
<head>
<title>Form to database</title>
</head>
<body> 
<%
'declare your variables
Dim name, email, comments
Dim sConnString, connection, sSQL, newstitle
'Receiving values from Form, assign the values entered to variables
newstitle = Request("tobeedited3") 


'declare SQL statement that will query the database 
sSQL = "INSERT into tbl_pressreleases (newstitle) values ('" & newstitle & "')" 
'sSQL = "INSERT into tbl_pressreleases (name, email, comments) values ('" & newstitle & "', '" & email & "', '" & comments & "')" 

'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
"Data Source=" & Server.MapPath("News.mdb") 
'create an ADO connection object 
Set connection = Server.CreateObject("ADODB.Connection")

'Open the connection to the database
connection.Open(sConnString)

'execute the SQL 
connection.execute(sSQL)

response.write "The form information was inserted successfully: "& newstitle
'Done. Close the connection object
connection.Close
Set connection = Nothing
%>
</body>
</html>
 
I am working on something very close to this... did you ever make any head way one this??? I don't have it work yet... I I am hung up on the asp part as well... i will put what I have later as well.
 
no, Im thinking about just using PHP to handle that part / aspect... lazy, but I might do that while I continue to look for a way to do it in asp.
 
Hey Tamak;

Don't give in yet. I have noticed that most of the good AJAX examples out on the web reference PHP and Ruby. There are not too many ASP examples.

I think the problem is that you are assuming the name of the field to be tobeedited3 - which is a logical assumption. Unfortunately this is most likey not the case.

Use the following code snippet below to reveal all form fields and their values passed to your receiving page (add_test.asp). Place it near the top. When you post anything to add_test.asp it will reveal the true name of the field that has been alluding you.

I took a look at Joseph Scott's Edit In Place code (latest version) and suspect that the field name will be "content" (line 160 of EditInPlace.js file). So, before even trying the code snippet below just try changing Request("tobeedited3") to Request("content"). If it works just keep the code snipet below for future reference.

Good Luck!

'//code snippet
For Each x in Request.Form
Response.Write x & ": " & Request.Form(x) & "<br>"
Next
Response.End
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top