Link to home
Start Free TrialLog in
Avatar of sr_millar
sr_millar

asked on

Edit Records

Hi All,

I am really struggling with this - have just started learning DreamWeaver and ColdFusion.  I have an access database I have created which will log IT support calls.  I have created a page with a record set filtering Status as No (i.e. it will display all tickets that have not been resolved).  It displays this in a table setup as a repeat region so it shows all applicable records.  I have added a column to the table and want an update button in there so I can edit a specific record.  I have tried my best but it is not working here is the code:  If anyone can tell me how to do this it would be great.

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfquery name="AllOpen" datasource="IT">
SELECT *
FROM Results
WHERE Results.Status = 'no'
</cfquery>
<cfset QueryString_AllOpen=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_AllOpen,"PageNum_AllOpen=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_AllOpen=ListDeleteAt(QueryString_AllOpen,tempPos,"&")>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="get" action="edit.cfm">
  <p>&nbsp;</p>
  <table width="60%"  border="1" cellspacing="2" cellpadding="2">
    <tr>
      <th scope="col">Update</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
    </tr>
    <cfoutput query="AllOpen">
      <tr>
        <td><input type="submit" name="Submit" value="Update"></td>
        <td>#AllOpen.TicketNo#</td>
        <td>#AllOpen.Name#</td>
        <td>#AllOpen.Priority#</td>
        <td>#AllOpen.DayReported#</td>
        <td>#AllOpen.MonthReported#</td>
        <td>#AllOpen.YearReported#</td>
        <td>#AllOpen.ProblemType#</td>
        <td>#AllOpen.ProblemOutline#</td>
        <td>#AllOpen.ProblemStatus#</td>
        <td>#AllOpen.Status#</td>
      </tr>
    </cfoutput>
  </table>
  <p>&nbsp;</p>
  <p>    </p>
</form>
</body>
</html>
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Try this:

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="updateTicket" default="">

<!--- Update Ticket --->
<cfif updateTicket neq "">
      <cfquery name="RsUpdate" datasource="IT">
      Update Results Set
      Status = 'yes'
      Where TicketNo = '#updateTicket#'
      </cfquery>
</cfif>

<cfquery name="AllOpen" datasource="IT">
SELECT *
FROM Results
WHERE Results.Status = 'no'
</cfquery>
<cfset QueryString_AllOpen=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_AllOpen,"PageNum_AllOpen=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_AllOpen=ListDeleteAt(QueryString_AllOpen,tempPos,"&")>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="get" action="edit.cfm">
  <p>&nbsp;</p>
  <table width="60%"  border="1" cellspacing="2" cellpadding="2">
    <tr>
      <th scope="col">Update</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
      <th scope="col">&nbsp;</th>
    </tr>
    <cfoutput query="AllOpen">
      <tr>
        <td>
          <input name="Update" type="button" id="Update" value="Update" onClick="edit.cfm?updateTicket=#AllOpen.TicketNo#"></td>
        <td>#AllOpen.TicketNo#</td>
        <td>#AllOpen.Name#</td>
        <td>#AllOpen.Priority#</td>
        <td>#AllOpen.DayReported#</td>
        <td>#AllOpen.MonthReported#</td>
        <td>#AllOpen.YearReported#</td>
        <td>#AllOpen.ProblemType#</td>
        <td>#AllOpen.ProblemOutline#</td>
        <td>#AllOpen.ProblemStatus#</td>
        <td>#AllOpen.Status#</td>
      </tr>
    </cfoutput>
  </table>
  <p>&nbsp;</p>
  <p>    </p>
</form>
</body>
</html>
Avatar of meth0
meth0

When you use dreamweaver server behaviours to displaymultiple  records specifically for editing purposes, the idea is to impliment "master-detail pages". The page which displays the recordset and repeat region is the master page. When you select or click on a record, the ID of that record is passed to the detail page where it displays that particular record in detail.

You want to create the detail page so that it displays the editable details of the record in textfields, check boxes etc inside a form with an update(submit) button. Once you make the changes to the redord details, you hit the button and the record is updated.

Dreamweaver (or cold fusion) help files should have tutorial files which outline the exact steps to do master-detail pages. Do a search in the help files for "master detail" and you'll find it.
Avatar of sr_millar

ASKER

Guys,

Thanks for the responses - ryancys - the code did not work, when I click the update button nothing happens at all.  Meth0 - Checked the help files and cant see anything about master details - am going to check the web for this and will let you know.

Stuart
Is the codes above from edit.cfm? or if it's different, try post the code of edit.cfm here...
ASKER CERTIFIED SOLUTION
Avatar of meth0
meth0

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Meth0,

Thanks for the tips - my help does not display it for some reason (I will look into it), but I did a google search for the terms you suggested and I found information on how to do it.

Thanks for the help.

Stuart