xphpx
|
| Posted: 06/24/2003, 12:27 AM |
|
Dears, I am using CCS 2.x with mysql and php.
I would like to use my listbox to collect data from the db for it's values (this is done). Now also I would like to make this listbox editable meaning I can add new values if they don't exist in the DB to the record.
Anyhelp ?
Rgds
|
|
|
 |
rrodgers
|
| Posted: 06/24/2003, 7:59 AM |
|
I don't know enough about the list box to say if you can make it directly editable. The link below shows how to use a separate window to create a new item in the list. This is a "port" from a CC example to CCS.
http://www.sylvancomputing.com/ccs
Click on the subwindow php link.
rob
|
|
|
 |
Aaron J. Scott
|
| Posted: 06/24/2003, 11:43 AM |
|
You can accomplish it with DHTML
Add this script substituting naming as necessary within the form tags.
Also add this event handler to the affected select tag.
<Select Name="thecontrolsname" oncontextmenu="AppendNewValues()">.....
<Script language="VBScript">
Sub AppendNewValues()
Dim srcElement, NewOption
Set srcElement = Window.Event.srcElement
Set NewOption = Document.CreateElement("option")
NewOption.Value = InputBox("New Value to Add.....")
NewOption.InnerText = InputBox("New Option's Display Text?")
srcElement.AppendChild NewOption
End Sub
</Script>
Be aware if you are using relational tables, the record referenced by the new value may not exist and thus this record will not appear in any queries as a result until the reference record related by the value has been added to the database.
This Script will execute for any selects you have added the event handler to.
|
|
|
 |
Don
|
| Posted: 06/24/2003, 1:25 PM |
|
The easiest way to do it is to have your listbox values be in a lookup table, then create a simple form for editing that table. Doing it this way, the same values are available elsewhere in your project if you need them without having to type them over again, making the site much easier to maintain in the longrun. The lookup table needs only an auto-incremented ID field as a key, and a text field for the values for the listbox.
Don
|
|
|
 |
JCarpton
|
| Posted: 06/24/2003, 1:26 PM |
|
>><Script language="VBScript">
Doesn't VBScript limit the browsers that can run this?
Jim
|
|
|
 |
Aaron J. Scott
|
| Posted: 06/26/2003, 3:51 PM |
|
Yes, but the point was an operable example. The script could easily be ported to javascript.
|
|
|
 |
rrodgers
|
| Posted: 06/26/2003, 4:33 PM |
|
The subwindow example actually adds the record into the db also. And it uses the same method for adding the option to the list but with javascript.
rob
|
|
|
 |