Forums
This topic is locked
Dynamic fields/update problem...
Posted 14 Feb 2002 22:01:42
1
has voted
14 Feb 2002 22:01:42 Eddie Appell posted:
I have a page that lists all of my records, one row at a time. Each record has a boolean value for one column that I'd like to be able to update by just selecting a checkbox that submits the form and updates the record. So, imagine this page that lists a name, then a checkbox next to it. The checkbox is checked if the value of the column for that record is True, unchecked if not. The whole page is a form. The problem I'm having is that I can't dynamically name the checkbox field using, for example, the ID of the record because it doesn't work in the "update" function that Macromedia provides...
I'm sure this has been done a lot, any ideas on how to best accomplish this? I can send the URL if you're interested.
Thanks for your help!
Eddie
Edited by - eappell on 14 Feb 2002 22:02:24
Replies
Replied 14 Feb 2002 23:22:24
14 Feb 2002 23:22:24 Dennis van Galen replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
The problem I'm having is that I can't dynamically name the checkbox field using, for example, the ID of the record because it doesn't work in the "update" function that Macromedia provides...
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Yes you can dynamically name your form-objects.
Just make sure you change the update function in the CODE view, resulting in a red "!" next to the server behavior, but that's ok.
if this is my textfield code:
<input type="text" name="FIRSTNAME" value="<%=(Recordset1.Fields.Item("FIRSTNAME".Value)%>" size="32">
And I make the name dynamic, like so:
<input type="text" name="<%=(Recordset2.Fields.Item("Textfieldname".Value)%>" value="<%=(Recordset1.Fields.Item("FIRSTNAME".Value)%>" size="32">
And this was my original update code:
// *** Update Record: set variables
if (String(Request("MM_update") != "undefined" &&
String(Request("MM_recordId") != "undefined" {
var MM_editConnection = MM_dfghd_STRING;
var MM_editTable = "EMPLOYEES";
var MM_editColumn = "EMPLOYEEID";
var MM_recordId = "" + Request.Form("MM_recordId" + "";
var MM_editRedirectUrl = "InsertOK.htm";
var MM_fieldsStr = "EMPLOYEEID|value|FIRSTNAME|value|LASTNAME|value|PHONE|value|STARTDATE|value|TITLE|value|DEPARTMENT|value|EXTENSION|value|EMAIL|value|PHOTO|value|NOTES|value";
var MM_columnsStr = "EMPLOYEEID|none,none,NULL|FIRSTNAME|',none,''|LASTNAME|',none,''|PHONE|',none,''|STARTDATE|',none,NULL|TITLE|',none,''|DEPARTMENT|',none,''|EXTENSION|',none,''|EMAIL|',none,''|PHOTO|',none,''|NOTES|',none,''";
Then I would need to replace all instances of FIRSTNAME with <%=(Recordset2.Fields.Item("Textfieldname".Value)%> .
Kinda like this:
// *** Update Record: set variables
if (String(Request("MM_update") != "undefined" &&
String(Request("MM_recordId") != "undefined" {
var MM_editConnection = MM_dfghd_STRING;
var MM_editTable = "EMPLOYEES";
var MM_editColumn = "EMPLOYEEID";
var MM_recordId = "" + Request.Form("MM_recordId" + "";
var MM_editRedirectUrl = "InsertOK.htm";
var MM_fieldsStr = "EMPLOYEEID|value|<%=(Recordset2.Fields.Item("Textfieldname".Value)%>|value|LASTNAME|value|PHONE|value|STARTDATE|value|TITLE|value|DEPARTMENT|value|EXTENSION|value|EMAIL|value|PHOTO|value|NOTES|value";
var MM_columnsStr = "EMPLOYEEID|none,none,NULL|<%=(Recordset2.Fields.Item("Textfieldname".Value)%>|',none,''|LASTNAME|',none,''|PHONE|',none,''|STARTDATE|',none,NULL|TITLE|',none,''|DEPARTMENT|',none,''|EXTENSION|',none,''|EMAIL|',none,''|PHOTO|',none,''|NOTES|',none,''";
That should do what you need, just remember that after changing the code of a server behavior, you CANNOT change the behavior through the server-behavior window, you have to alter the code manually.
But this way, we can have dynamic names even if the original behavior doesn't support it.
Maybe something for the wishlist for UD5.
Let me know if you get it to work.
With kind regards,
Dennis van Galen
Webmaster KPN Nederland
Financial and Information Services
The problem I'm having is that I can't dynamically name the checkbox field using, for example, the ID of the record because it doesn't work in the "update" function that Macromedia provides...
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Yes you can dynamically name your form-objects.
Just make sure you change the update function in the CODE view, resulting in a red "!" next to the server behavior, but that's ok.
if this is my textfield code:
<input type="text" name="FIRSTNAME" value="<%=(Recordset1.Fields.Item("FIRSTNAME".Value)%>" size="32">
And I make the name dynamic, like so:
<input type="text" name="<%=(Recordset2.Fields.Item("Textfieldname".Value)%>" value="<%=(Recordset1.Fields.Item("FIRSTNAME".Value)%>" size="32">
And this was my original update code:
// *** Update Record: set variables
if (String(Request("MM_update") != "undefined" &&
String(Request("MM_recordId") != "undefined" {
var MM_editConnection = MM_dfghd_STRING;
var MM_editTable = "EMPLOYEES";
var MM_editColumn = "EMPLOYEEID";
var MM_recordId = "" + Request.Form("MM_recordId" + "";
var MM_editRedirectUrl = "InsertOK.htm";
var MM_fieldsStr = "EMPLOYEEID|value|FIRSTNAME|value|LASTNAME|value|PHONE|value|STARTDATE|value|TITLE|value|DEPARTMENT|value|EXTENSION|value|EMAIL|value|PHOTO|value|NOTES|value";
var MM_columnsStr = "EMPLOYEEID|none,none,NULL|FIRSTNAME|',none,''|LASTNAME|',none,''|PHONE|',none,''|STARTDATE|',none,NULL|TITLE|',none,''|DEPARTMENT|',none,''|EXTENSION|',none,''|EMAIL|',none,''|PHOTO|',none,''|NOTES|',none,''";
Then I would need to replace all instances of FIRSTNAME with <%=(Recordset2.Fields.Item("Textfieldname".Value)%> .
Kinda like this:
// *** Update Record: set variables
if (String(Request("MM_update") != "undefined" &&
String(Request("MM_recordId") != "undefined" {
var MM_editConnection = MM_dfghd_STRING;
var MM_editTable = "EMPLOYEES";
var MM_editColumn = "EMPLOYEEID";
var MM_recordId = "" + Request.Form("MM_recordId" + "";
var MM_editRedirectUrl = "InsertOK.htm";
var MM_fieldsStr = "EMPLOYEEID|value|<%=(Recordset2.Fields.Item("Textfieldname".Value)%>|value|LASTNAME|value|PHONE|value|STARTDATE|value|TITLE|value|DEPARTMENT|value|EXTENSION|value|EMAIL|value|PHOTO|value|NOTES|value";
var MM_columnsStr = "EMPLOYEEID|none,none,NULL|<%=(Recordset2.Fields.Item("Textfieldname".Value)%>|',none,''|LASTNAME|',none,''|PHONE|',none,''|STARTDATE|',none,NULL|TITLE|',none,''|DEPARTMENT|',none,''|EXTENSION|',none,''|EMAIL|',none,''|PHOTO|',none,''|NOTES|',none,''";
That should do what you need, just remember that after changing the code of a server behavior, you CANNOT change the behavior through the server-behavior window, you have to alter the code manually.
But this way, we can have dynamic names even if the original behavior doesn't support it.
Maybe something for the wishlist for UD5.
Let me know if you get it to work.
With kind regards,
Dennis van Galen
Webmaster KPN Nederland
Financial and Information Services