Ephox Home Page Ephox Home Page  
Search
Buy/Upgrade
 
 Developers
Developers Home
EditLive! for Java
EditLive! for Windows
System Requirements
Getting Started
Integration Samples
Articles
API Reference
EditLive! for XML
Discussion Forums

Sample FTP Application for Active Server Pages

Ephox, September 2001

Introduction
Pre-requisites
Retrieving the Sample Source Code
Files included in this sample
The Database
I_ADOVBS.ASP
I_DATABASE.ASP
The Index Page (start.asp)
Adding a File to the Database (add.asp and xt_add.asp)
Adding or Modifying the FTP Server Settings (settings.asp and xt_settings.asp)
Editing an Existing File (edit.asp)

Introduction

This sample shows how EditLive! can be used to update a flat file Web site via FTP. The system allows users to load an existing web page hosted on any web server into EditLive!, make changes, and then save the file back to their web server.  This means that end users can edit their web pages on the fly without having to physically transfer files between their local computer and their web server. 

The FTP settings of the remote server where the Web files are stored are kept in an online database.  The details of the files available for editing within EditLive! are also stored in this database. 

Pre-requisites

This sample uses client-side JavaScript within HTML.  Active Server Pages using VBScript is used for the server-side scripting.  Please ensure that before working through this sample you have read Using EditLive! with Single Web Files via FTP.

Retrieving the Sample Source Code

The source code for this sample will have been installed on your machine when you installed the Ephox EditLive! 2.0 Development Kit.  To view the source code please click on Start->Programs->Ephox EditLive!->Open Source Code.  If you have Microsoft IIS or Personal Web Server installed on your local machine, to run this sample through your web server please click on the shortcut in the Ephox EditLive! folder in the Programs menu.

Files included in this sample

Below is a table outlining the eight files included in this sample. 

i_adovbs.asp This file allows the use of ADO objects for creating database recordsets.
i_database.asp This file defines the connection string used to connect to the online database.
start.asp This file searches the database and creates a list of files that are available for editing within EditLive!.  It also supplies links to allow users to add file details to the database or change their FTP settings within the database.
add.asp This file allows users to add the details of files to be edited using EditLive! to the database.
xt_add.asp This file adds the file details to the database.
edit.asp This file loads a nominated file into EditLive! for modification.
settings.asp This file displays the FTP settings of the remote server that are recorded in the database, and allows the user to change these settings.
xt_settings.asp This file updates in the database changes made to the FTP settings.

The Database

The database used in this sample is a Microsoft Access database named content.mdb.  Two tables are used in this sample; ftp and pages. Below is a table outlining the fields within these database tables and a description of the information each field stores.

ftp

user_id A code used to identify a particular user.
ftp_server The FTP name of the remote server where the Web files are stored.  This is the FTP server name used to connect to the server using any FTP client (e.g. www.ephox.com).
ftp_port The number of the port used to create an FTP connect to the remote server where the Web files are stored.  The usual value for this is 21.
ftp_username The username used to log on to the remote FTP server.
ftp_passsword The password used to log on to the remote FTP server.
ftp_initial The directory, off the root directory of the server, where the files are stored.
N.B. This value is optional.  The directory name can be included with the filename if files reside in several different directories.
webroot The URL that points to the specified server and initial directory (if specified) in the Web browser (e.g. http://www.ephox.com/product).

pages

user_id A code used to identify a particular user.
filename The name of the file to be loaded into EditLive! for modification, including the file extension (e.g. home.htm).  This name may also include the directory name if the file is stored in a directory off the directory that the FTP details log in to (e.g. product/home.htm).
description A description of the file for easy identification by the end user.

I_ADOVBS.ASP

Purpose - This file is used to define the ADO objects that this sample uses to connect to the online database.  This is a standard file issued by Microsoft as part of the ASP library.  This file is included whenever interaction with the online database is required within a page.

I_DATABASE.ASP

Purpose - This file defines the ADO connection string used to connect with the online database.  Therefore, it is also included whenever a page interacts with the database to retrieve or save information.

Step 1 - Locate the full path of the database file, content.mdb.

' Find the path of the database file
strCurrentDir = Server.Mappath("content.mdb")

Step 2 - Calculate the relative path of the database file to the location of the sample files that will use the connection string.

' Calculate the database file path relative to the sample files
lngPosLastSlash = InStrRev(strCurrentDir,"\")
lngPosSecondLastSlash = InStrRev(strCurrentDir,"\",lngPosLastSlash-1)
lngPosThirdLastSlash = InStrRev(strCurrentDir,"\",lngPosSecondLastSlash-1)
strDBLocationDir = Left(strCurrentDir,lngPosThirdLastSlash)
strDBLocationPath = strDBLocationDir & "database" & "\content.mdb"

Step 3 - Define a connection string variable to be used for the ADO database connections.

' Construct the connection string for the ADO Connection
strConnection = "DBQ=" & strDBLocationPath & ";" & _
"DefaultDir=" & strDBLocationDir & ";" & _
"UID=admin;" & _
"Driver= {Microsoft AccessDriver(*.mdb)};DriverId=25;FIL=MS Access;"

The Index Page (start.asp)

Purpose - The index page lists all of the files available for editing within EditLive!.  It also provides links to:

  • add the details of a file to the database; and
  • edit the FTP settings of the remote server stored in the database.

Step 1 - Include the i_adovbs.asp and i_database.asp files to connect to the database.

<!--#INCLUDE FILE="i_database.asp"-->
<!--#INCLUDE FILE="i_adovbs.asp"-->

Step 2 - Retrieve the user_id from the URL and assign it to a variable for later user.

<%
' Get user_id from page URL and set to a variable
Set User = Request.QueryString("user_id")
%>

Step 3 - Create a link in the page to the file add.asp to allow users to add file details to the database.  This address needs to include the user_id for accessing the correct details in the database.

<!-- Link to add file details to the database -->
<p><a href=
"add.asp?user_id=<%=User%>">Add a File to the Database</a></p>

Step 4 - Create a link in the page to the file settings.asp to allow users to modify their FTP settings in the database.  This address needs to include the user_id for accessing the correct details in the database.

<!-- Link to change FTP settings -->
<p><a href=
"settings.asp?user_id=<%=User%>">Modify your FTP Settings</a></p>

Step 5- Connect to the database and retrieve all of the existing file details listed in the pages table.  Also, retrieve the WebRoot value from the ftp table for creating a link to view the page in the Web browser.

<%

' Instantiate an ADO Connection object
Set objDBConn= Server.CreateObject("ADODB.Connection")

' Open the connection using the connection string
' defined in the included file "i_database.asp"
objDBConn.Open strConnection

' Instantiate an ADO Recordset object for the page details
Set rsPages = Server.CreateObject("ADODB.Recordset")

' Construct the SQL to be used to open the recordset for the page details
CommandText = "SELECT * FROM pages WHERE user_id = '" & User & "'"

' Open the recordset for the page details with a static cursor
rsPages.Open CommandText, objDBConn, adOpenStatic

' Instantiate an ADO Recordset object for the base web address for the files
Set rsWebRoot = Server.CreateObject("ADODB.Recordset")

' Construct the SQL to be used to open the recordset for the base web address for the files
CommandText = "SELECT WebRoot FROM ftp"

' Open the recordset for the base web address for the files with a static cursor
rsWebRoot.Open CommandText, objDBConn, adOpenStatic

'Assign the base web address for the pages to a variable
Set strWebroot = rsWebRoot("webroot")

' Are there any records in the recordset?
If Not rsPages.BOF Then

%>

Step 6 - Use embedded ASP to loop through the recordset of files to create a table which lists all of the files by description.  Then, for each page, create a link to:

  • View the page in the Web browser using the actual Web address of the file; and
  • Edit the page using EditLive! (a link to the file edit.asp).

Append the user_id  to the edit page link so that the correct file and FTP information for the user is retrieved.

<TABLE cellpadding=3 cellspacing=0 border=0>
<TR>
<TH width=
"250">Description</TH>
<TH width=
"250">Filename</TH>
<TH>
Available Actions</TH>
</TR>

<%
' There are records. Loop through all the records in the
' recordset and write out a table row for each record
Do While Not rsPages.EOF
%>

<TR>
<TD>
<%=rsPages("description")%></TD>
<TD>
<%=rsPages("filename")%></TD>
<TD><A href=
"<%=strWebroot%>/<%=rsPages("filename")%>">View</A> |
<A href="edit.asp?user_id=<%=User%>&filename=<%=rsPages("filename")%>">Edit</A>
</TD>
</TR>

<%
' Move to the next row in the recordset
rsPages.MoveNext()
Loop
%>

</TABLE>

Step 7 - Add an ELSE statement to the IF loop to let users know if there are no records in the database.

<%
Else
' There are no records. Tell the user.
%>

<P>There are no records in the database. Click <STRONG>Add a File to the Database</STRONG>
to add a record to the database.</P>

<%
End If
%>

Step 8 - Release the memory being used for the database connection and the article recordsets.

<%
' Release the memory consumed by the objects
Set rsPages = Nothing
Set rsWebRoot = Nothing
Set objDBConn = Nothing
%>

Adding a File to the Database (add.asp and xt_add.asp)

Purpose - The file add.asp is used to specify the details of a file to add to the database.  The file xt_add.asp is used to add the file information to the database.

Add.asp

Step 1 - Start with a standard HTML page.

<HTML>
<HEAD>
<TITLE>
Add a File to the Database</TITLE>
<LINK rel=
"stylesheet" href="sample.css">
</HEAD>
<BODY>
</BODY>
</HTML>

Step 2 - Add a heading to the page of "Add a File to the Database".

<BODY>
<H1>
Add a File to the Database</H1>

Step 3 - Create a form in the page.  Enter the processing file name, xt_add.asp, in the action attribute of the FORM tag.

<%
' This form contains text areas for the file name and description
%>

<FORM action="xt_add.asp" method="POST" name="fileForm">
</FORM>

Step 4 - Add two text fields to the form; one for the file name and one for the file description.

<%' Text areas for entering file name and description %>
<P>Description: <INPUT type="text" name="description" size="20"></P>
<P>
File Name: <INPUT type="text" name="filename" size="20"></P>

Step 5 -Add a hidden form object to store the user_id that is retrieved from the URL.

<%' Hidden form object to store user ID %>
<INPUT type="hidden" name="user_id" value="<%=Request.QueryString("user_id")%>">

Step 6 - Add two buttons to the form; one Submit button that will post the form contents to the processing page, xt_add.asp, and one Cancel button that will take the browser back to the previous page.

<% ' Form buttons %>
<P><INPUT type="submit" value="Add File" name="Add">
<INPUT type=
"button" value="Cancel" name="Cancel" onclick="javascript:history.back();"></P>

Xt_add.asp

Step 1 - Include the i_adovbs.asp and i_database.asp files to connect to the database.

<%
' Include I_DATABASE.ASP which defines the database connection
' Include I_ADOVBS.ASP which defines ADO constants.
%>
<!--#INCLUDE FILE="i_database.asp"-->
<!--#INCLUDE FILE="i_adovbs.asp"-->

Step 2 - Create a connection to the database and create a new recordset to add the new file information.

<%

' Instantiate an ADO Connection object
Set objDBConn= Server.CreateObject("ADODB.Connection")

' Open the connection using the connection string
' defined in the included file "i_database.asp"
objDBConn.Open strConnection

' Instantiate an ADO Recordset object
Set rsPages = Server.CreateObject("ADODB.Recordset")

' Set the type of cursor we will use
rsPages.CursorType = adOpenKeyset

' Set the lock type for the records so that only when we update
' a record is that record locked by ADO
rsPages.LockType = adLockOptimistic

' Open the pages table
rsPages.Open "pages", objDBConn, , , adCmdTable

Step 3 - Add a new record to the recordset.

' Add a new record
rsPages.AddNew

Step 4 - Assign the values of the form objects to the relevant recordset fields.

' Set the values

If Request.Form("filename") <> "" Then
rsPages("filename") = Request.Form("filename")
End If

If Request.Form("description") <> "" Then
rsPages("description") = Request.Form("description")
End If

If Request.Form("user_id") <> "" Then
rsPages("user_id") = Request.Form("user_id")
End If

Step 5 - Save the new record to the database.

' Save the record
rsPages.Update

Step 6 - Destroy the database objects.

' Destroy the objects
rsPages.Close
objDBConn.Close
Set rsPages = Nothing
Set objDBConn = Nothing

Step 7 - Redirect the web browser back to the index page, appending the user_id.

' Go back to the start page
Response.Redirect("start.asp?user_id=" & Request.Form("user_id"))
%>

Adding or Modifying the FTP Server Settings (settings.asp and xt_settings.asp)

Purpose - The file settings.asp is used to add or modify the FTP server details in the ftp table of the database.  The file xt_settings.asp is used to replace the record in the database with the new FTP server information.

Add.asp

Step 1 - Start with a standard HTML page.

<HTML>
<HEAD>
<TITLE>
Modify FTP Settings</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>

Step 2 - Add a heading to the page of "Modify FTP Settings".

<BODY>
<H1>Modify FTP Settings</H1>

Step 3 - Create a form in the page.  Enter the processing file name, xt_settings.asp, in the action attribute of the FORM tag.

<%
' This form contains text areas for the all of the FTP settings
%>

<FORM action="xt_settings.asp" method="POST" name="fileForm">
</FORM>

Step 4 - Include the i_adovbs.asp and i_database.asp files to connect to the database.

<%
' Include I_DATABASE.ASP which defines the database connection
' Include I_ADOVBS.ASP which defines ADO constants.
%>
<!--#INCLUDE FILE="i_database.asp"-->
<!--#INCLUDE FILE="i_adovbs.asp

Step 5 - Retrieve the user_id from the page URL and assign it to a variable.

' Get user_id from page URL and set to a variable
Set User = Request.QueryString("user_id")

Step 6 - Create a connection to the database.

' Instantiate an ADO Connection object
Set objDBConn= Server.CreateObject("ADODB.Connection")

' Open the connection using the connection string
' defined in the included file "i_database.asp"
objDBConn.Open strConnection

Step 7 -Create a recordset containing the FTP details from the ftp database table, for the specified user_id.

' Define the SQL query for retrieving the FTP details
strCommandText = "SELECT * FROM ftp WHERE user_id = '" & User & "'"

' Retrieve the recordset
Set rsFTP = objDBConn.Execute(strCommandText, , adCmdText)

Step 8 - If the FTP details exist, assign the FTP information to set variables.

If Not rsFTP.BOF Then
' The record is found

' The FTP server
strFTPServer = rsFTP("ftp_server")

' The FTP server port
If rsFTP("ftp_port").ActualSize > 0 Then
nFTPServerPort = rsFTP("ftp_port")
Else
nFTPServerPort = 21
End If

' The FTP username
If rsFTP("ftp_username").ActualSize > 0 Then
strFTPUsername = rsFTP("ftp_username")
Else
strFTPUsername = ""
End If

' The FTP password
If rsFTP("ftp_password").ActualSize > 0 Then
strFTPPassword = rsFTP("ftp_password")
Else
strFTPPassword = ""
End If

' The FTP Initial Directory
If rsFTP("ftp_initial").ActualSize > 0 Then
strFTPInitialDirectory = rsFTP("ftp_initial")
Else
strFTPInitialDirectory = ""
End If

' The FTP WebRoot
strWebRoot = rsFTP("webroot")

%>

Step 9 - Add text fields to the form, one for each of the FTP settings.  Make the value of the text area equal to the relevant variable name, as defined in Step 8.

<%' Text areas for FTP settings %>
<P>FTP Server Name&nbsp;&nbsp;<INPUT type="text" name="ftp_server" value="<%=strFTPServer%>" size="20"><BR>
FTP Server Port Number&nbsp;&nbsp;
<INPUT type="text" name="ftp_port" value="<%=nFTPServerPort%>" size="20"><BR>
FTP Server Username&nbsp;&nbsp;
<INPUT type="text" name="ftp_username" value="<%=strFTPUsername%>" size="20"><BR>
FTP Server Password&nbsp;&nbsp;
<INPUT type="text" name="ftp_password" value="<%=strFTPPassword%>" size="20"><BR>
FTP Initial Directory&nbsp;&nbsp;
<INPUT type="text" name="ftp_initial" value="<%=strFTPInitialDirectory%>" size="20"><BR>
Webroot&nbsp;&nbsp;
<INPUT type="text" name="webroot" value="<%=strWebRoot%>" size="20"></P>

Step 10 -Add a hidden form object to store the user_id, which is retrieved from the URL.

<%' Hidden form object to store user ID %>
<INPUT type="hidden" name="user_id" value="<%=Request.QueryString("user_id")%>">

Step 11 - Add two buttons to the form; one Submit button that will post the form contents to the processing page, xt_settings.asp, and one Cancel button that will take the browser back to the previous page.

<% ' Form buttons %>
<P><INPUT type="submit" value="Update FTP Settings" name="Update">
<INPUT type="button" value="Cancel" name="Cancel" onclick="javascript:history.back();"></P>

Xt_settings.asp

Step 1 - Include the i_adovbs.asp and i_database.asp files to connect to the database.

<%
' Include I_DATABASE.ASP which defines the database connection
' Include I_ADOVBS.ASP which defines ADO constants.
%>
<!--#INCLUDE FILE="i_database.asp"-->
<!--#INCLUDE FILE="i_adovbs.asp"-->

Step 2 - Create a connection to the database and create a new recordset to add the FTP information.

<%

' Instantiate an ADO Connection object
Set objDBConn= Server.CreateObject("ADODB.Connection")

' Open the connection using the connection string
' defined in the included file "i_database.asp"
objDBConn.Open strConnection

' Instantiate an ADO Recordset object
Set rsSettings = Server.CreateObject("ADODB.Recordset")

' Set the type of cursor we will use
rsSettings.CursorType = adOpenKeyset

' Set the lock type for the records so that only when we update
' a record is that record locked by ADO
rsSettings.LockType = adLockOptimistic

' Open the ftp  table
rsSettings.Open "ftp", objDBConn, , , adCmdTable

Step 3 - Select the record containing the existing FTP settings to delete from the database.

' Select the record to delete
rsSettings.Filter = "user_id = " & Request.Form("user_id")

Step 4 - Add a new record to the recordset.

' Add a new record
rsSettings.AddNew

Step 5 - Assign the values of the form objects from the settings.asp page to the relevant recordset fields.

If Not rsSettings.BOF Then

' Set the values
If Request.Form("ftp_server") <> "" Then
rsSettings("ftp_server") = Request.Form("ftp_server")
End If

If Request.Form("ftp_port") <> "" Then
rsSettings("ftp_port") = Request.Form("ftp_port")
End If

If Request.Form("ftp_initial") <> "" Then
rsSettings("ftp_initial") = Request.Form("ftp_initial")
End If

If Request.Form("ftp_username") <> "" Then
rsSettings("ftp_username") = Request.Form("ftp_username")
End If

If Request.Form("ftp_password") <> "" Then
rsSettings("ftp_password") = Request.Form("ftp_password")
End If

If Request.Form("webroot") <> "" Then
rsSettings("webroot") = Request.Form("webroot")
End If

Step 6 - Save the new record to the ftp table.

' Save the record
rsSettings.Update

Step 7 - Destroy the database objects.

' Destroy the objects
rsPages.Close
objDBConn.Close
Set rsSettings = Nothing
Set objDBConn = Nothing

Step 8 - Redirect the web browser back to the index page, appending the user_id.

' Go back to the start page
Response.Redirect("start.asp?user_id=" & Request.Form("user_id"))
%>

Editing an Existing File (edit.asp)

Purpose - The file edit.asp loads a selected file into EditLive! for modification.  Once the file has been modified, the user simply needs to press the Save button to save the file directly back to the remote Web server.

Step 1 - Start with a standard HTML page containing EditLive! running in FTPStandard mode.  To see the steps involved in creating this page please see Using EditLive! with Single Web Files via FTP.

<HTML>
<HEAD>
<%
' These script files initialize the EditLive! API so that the EditLive!
' properties and methods may be set to customise EditLive!.
%>

<SCRIPT language="JavaScript" src="../../editlive/editLive4.js"></SCRIPT>
<SCRIPT language
="VBScript" src="../../editlive/editLive4.vbs"></SCRIPT>
</HEAD>

<BODY>

<%
' Instantiate the EditLive! object on your web page using client-side JavaScript
%>

<SCRIPT language="JavaScript">
<!--
//Important: set the directory where EditLive! download files can be found
EditLiveGlobal.setDownloadDirectory("../../editlive/");

//Create the EditLive! object
var editLive1 = new EditLive("Plugin1", "100%", 300);

//Assign an onload function to initialize the properties and methods
editLive1.onload = EditLive1_onload;

//This function specifies the initial EditLive! properties and methods
function EditLive1_onload()
{
// Set the user interface to database mode
editLive1.setEditLiveMode('FTPStandard');

// Set the image mode to allow inserting images only from the server
editLive1.setImageMode('ServerOnly');

// Initialize the FTP server
editLive1.setFTPServer('');
editLive1.setFTPServerPort();
editLive1.setFTPUsername('');
editLive1.setFTPPassword('');
editLive1.setFTPInitialDirectory('');

// Set the base URL to render relative image addresses
editLive1.setWebRoot('');

// Load the file
editLive1.loadFile('');

// Turn on HTML editing mode to allow users to edit raw HTML
editLive1.setEditorMode("FULL");
}

//-->
</SCRIPT>

</BODY>
</HTML>

Step 2 - Add a heading to the page of "Edit Document".

<BODY>
<H1>
Edit Document</H1>

Step 3 - Create a form in the page around the EditLive! object. In the action attribute of the FORM tag, create a link back to the index page for when the user has finished editing the current page within EditLive!.

<%
' This form contains EditLive!, a Save button, a Save and Close button and a Cancel button.
%>

<FORM name="form1" action="start.asp?user_id=<%=User%>" method="get">

</FORM>

Step 4 - Include the i_adovbs.asp and i_database.asp files to connect to the database.

<%
' Include I_DATABASE.ASP which defines the database connection
' Include I_ADOVBS.ASP which defines ADO constants.
%>
<!--#INCLUDE FILE="i_database.asp"-->
<!--#INCLUDE FILE="i_adovbs.asp

Step 5 - Retrieve the user_id and filename information from the page URL and assign them each to a set variable.

' Get user_id from page URL and set to a variable
Set User = Request.QueryString("user_id")

' Get filename from the page URL and set to a variable
Set Filename = Request.QueryString("filename")

Step 6 - Create a connection to the database.

' Instantiate an ADO Connection object
Set objDBConn= Server.CreateObject("ADODB.Connection")

' Open the connection using the connection string
' defined in the included file "i_database.asp"
objDBConn.Open strConnection

Step 7 - For the specified user_id, create a recordset containing the FTP details from the ftp database table.

' Define the SQL query for retrieving the FTP details
strCommandText = "SELECT * FROM ftp WHERE user_id = '" & User & "'"

' Retrieve the recordset
Set rsFTP = objDBConn.Execute(strCommandText, , adCmdText)

Step 8 - If the FTP details exist, assign the FTP information to set variables.

If Not rsFTP.BOF Then
' The record is found

' The FTP server
strFTPServer = rsFTP("ftp_server")

' The FTP server port
If rsFTP("ftp_port").ActualSize > 0 Then
nFTPServerPort = rsFTP("ftp_port")
Else
nFTPServerPort = 21
End If

' The FTP username
If rsFTP("ftp_username").ActualSize > 0 Then
strFTPUsername = rsFTP("ftp_username")
Else
strFTPUsername = ""
End If

' The FTP password
If rsFTP("ftp_password").ActualSize > 0 Then
strFTPPassword = rsFTP("ftp_password")
Else
strFTPPassword = ""
End If

' The FTP Initial Directory
If rsFTP("ftp_initial").ActualSize > 0 Then
strFTPInitialDirectory = rsFTP("ftp_initial")
Else
strFTPInitialDirectory = ""
End If

' The FTP WebRoot
strWebRoot = rsFTP("webroot")

%>

Step 9 - Set the EditLive! FTP properties in the EditLive1_onload() function to equal the variables defined in Step 8.

// Initialize the FTP server
editLive1.setFTPServer('<%=strFTPServer%>');
editLive1.setFTPServerPort(<%=nFTPServerPort%>);
editLive1.setFTPUsername('<%=strFTPUsername%>');
editLive1.setFTPPassword('<%=strFTPPassword%>');
editLive1.setFTPInitialDirectory('<%=strFTPInitialDirectory%>');

// Set the base URL to render relative image addresses
editLive1.setWebRoot('<%=strWebRoot%>');

Step 10 - Again, in the EditLive1_onload() function, set the loadFile method to the name of the file to be loaded into EditLive! for modification.

// Load the file
editLive1.loadFile('<%=Filename%>');

Step 11 - Add 3 buttons to the form to allow the user to:

  • Save the file within EditLive!.
  • Save the file within EditLive! and move back to the Start page.
  • Move back to the index page without saving the changes made within EditLive!.

Make the Save&Close button a submit button, so that when it is pressed, the browser will move to the index page as indicated in the action attribute of the FORM tag.

<P><INPUT type="button" value="Save" id="save" name="save" onclick="btnSave_onclick()">
<INPUT type=
"submit" value="Save & Close" id="save&close" name="save&close" onclick="btnSaveandClose_onclick()">
<INPUT type=
"button" value="Cancel" onclick="javascript:history.back();" id="button1" name="button1"></P>

Step 12 - Create the btnSave_onclick() and btnSaveandClose_onclick() functions to save the file within EditLive! back to the remote FTP server when either button is pressed.

// This function saves the file when the Save button is pressed
function btnSave_onclick()
{
editLive1.saveFile();
}

// This function saves the file when the form is submitted
function btnSaveandClose_onclick()
{
editLive1.saveFile();
}

 

 

Copyright © 1999-2005 Ephox Corporation. All Rights Reserved. 'Ephox' is a registered trademark of Ephox Corporation.
Java and the Java Powered logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.