birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-01-26 09:38
Návrat hore
Odpovedať s citátom
|
I created a
| Kód: |
$opts['fdd']['firstlast']['values']['table'] = 'actors';
$opts['fdd']['firstlast']['values']['column'] = 'code';
$opts['fdd']['firstlast']['values']['orderby'] = 'name';
$opts['fdd']['firstlast']['values']['description'] = 'name';
$opts['fdd']['firstlast']['select'] = 'D'; |
for users to be able to select an option from the dropdown list
At the same time I need to give users a possibility to enter _new_ values for this table field. How can I do that?
P.S. I suppose that might be done via values2 help and a small JS code which replaces the dropdown list with simple <input type=text> edit
|
birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-01-26 09:43
Návrat hore
Odpovedať s citátom
|
To my mind there has to be a configuration option for doing that 'cause many users definately need such an ability
|
hbernard
Založený: 23.03.2003
Príspevky: 159
Bydlisko: FRANCE
Zaslal: 2004-01-26 10:29
Návrat hore
Odpovedať s citátom
|
| birdie Napísal: |
| To my mind there has to be a configuration option for doing that 'cause many users definately need such an ability |
There are some planned features that will allow this (using some triggers and specific fields), but this is not currently implemented.
|
birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-01-26 13:17
Návrat hore
Odpovedať s citátom
|
Is it possible to implement this feature right now? Any code, patch or ugly hack ;) is highly appreciated!
|
nepto
Založený: 06.01.2003
Príspevky: 320
Bydlisko: Phoenix, Arizona (USA)
Zaslal: 2004-01-26 14:44
Návrat hore
Odpovedať s citátom
|
I would recommend you to create an additional table.
Do table lookup into this new table to get values for drop-down menu.
Than you can generate new phpMyEdit calling script for this table to allow users enter new values there.
_________________ Ondrej Jombik (Nepto)
Visit my
homepage
, review my recent
CV
or
projects
and give me some
feedback
.
|
birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-01-27 09:44
Návrat hore
Odpovedať s citátom
|
Good idea! Thanks a lot!
Anyhow that whould be nice to incorporate this feature (entering new values instead of drop down list on value select) into phpMyEdit config.
I think it's trivial to implement this via simple JavaScript and and an additional form which stores the nessesary fields in <input type=hidden> or extra $_GET values passed to the php script which are initialized upon selecting the item from the drop down list and then reloading the whole page.
I'm awaiting for the implementation!
|
hbernard
Založený: 23.03.2003
Príspevky: 159
Bydlisko: FRANCE
Zaslal: 2004-01-27 10:12
Návrat hore
Odpovedať s citátom
|
Well, this is not so trivial, mainly because :
- there is no entry-and-drop-down widget in basic HTML forms
- In current production Mysql, there is no stored procedure, so you have to play with triggers.
But I would be interested to see you trivial patch for this feature.
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2004-01-27 14:09
Návrat hore
Odpovedať s citátom
|
it would be possible to put an extra button in 'help' area. after pressing, some data would be saved (entered data and other variables). user would be redirected to the second page to add desired entry. on the second page there would be a link back to first.
the problem will be storing variables needed to generate this page (filters, sorting, ...)(see in features forum). but for a simple purpouse you need just two ('operation' and 'rec').
but you need sessions. (it can be done without them, but ... good luck)
|
birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-02-05 10:16
Návrat hore
Odpovedať s citátom
|
| Kód: |
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function comboChange(srcElement,maxl)
{
if (srcElement.options[srcElement.selectedIndex].value=="_"){
srcElement.outerHTML="<INPUT TYPE=Text NAME="+srcElement.name+" SIZE=40 MAXLENGTH="+maxl+">";
}
}
</SCRIPT>
</head>
<body>
<SELECT NAME="COMPANY" SIZE="1" onchange="comboChange(this,255)" style="width:215;">
<OPTION VALUE="_"><New value>
<OPTION VALUE="select_from_db1">select_from_db1
<OPTION VALUE="select_from_db2">select_from_db2
<OPTION VALUE="select_from_db3">select_from_db3
</SELECT>
</body>
</html>
|
A new value should be initialized via values2 option setting it to value "_" and name "New Name" respectively. This code works perfectly in the Internet Explorer. If you could adopt it for using with Gecko based browsers I would be entirely happy. And please put this code into phpMyEdit or at least into CVS. I need it working in the nearest five days.
Thanks a lot
|
birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-02-05 10:22
Návrat hore
Odpovedať s citátom
|
In the example of the page I posted previously upon selecting a value "<New Value>" a combobox magically turns into simple edit control and that is exacly what I need! I think other users will love it too. BTW, you could simply add one extra option for all drop down variables like 'options' => "N", meaning a user can add a New value instead of drop down list if he/she desired.
|
birdie
Založený: 26.01.2004
Príspevky: 7
Zaslal: 2004-02-05 12:05
Návrat hore
Odpovedať s citátom
|
Hurrah!
This code works both for IE and Gecko based browser, i.e. almost everywhere
| Kód: |
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var _emptyTags = {
"IMG": true,
"BR": true,
"INPUT": true,
"META": true,
"LINK": true,
"PARAM": true,
"OPTION":true,
"HR": true
};
HTMLElement.prototype.__defineGetter__("outerHTML", function () {
var attrs = this.attributes;
var str = "<" + this.tagName;
for (var i = 0; i < attrs.length; i++)
str += " " + attrs[i].name + "=\"" + attrs[i].value + "\"";
if (_emptyTags[this.tagName])
return str + ">";
return str + ">" + this.innerHTML + "</" + this.tagName + ">";
});
HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var df = r.createContextualFragment(sHTML);
this.parentNode.replaceChild(df, this);
});
function comboChange(srcElement,maxlength)
{
if (srcElement.options[srcElement.selectedIndex].value=="_"){
srcElement.outerHTML="<input type=text name="+srcElement.name+" size=40 maxlength="+maxlength+">";
}
}
</SCRIPT>
</head>
<body>
<select name="COMPANY" size="1" onchange="comboChange(this,255)" style="width:215;">
<option value="_"><New value>
<option value="select_from_db1">select_from_db1
<option value="select_from_db2">select_from_db2
<option value="select_from_db3">select_from_db3
</select>
</body>
</html>
|
|
hbernard
Založený: 23.03.2003
Príspevky: 159
Bydlisko: FRANCE
Zaslal: 2004-02-05 22:05
Návrat hore
Odpovedať s citátom
|
Interesting.
But :
- like the 'tab' feature this will not work in js disabled browsers.
- option 'N' is a bad API ;-)
AND :
Currently, this is only useful for preset values with no join table. I mean you store the value in the field, not an ID.
This may be OK, but you have to be aware that most of the time, dropdown are used to display values from another table.
Anyway, if you really want this to go into phpMyEdit, you should open a bug report.
But maybe this could be an extension ?
|
|
Odoslať novú tému
Odpovedať na tému
|