Ken
|
| Posted: 02/08/2003, 9:26 AM |
|
Has anyone ever created a form with two list boxes, one contains values from another table. When those values are selected, you click a button to move the values to the second list box. Similar to how CCS adds tables in the form creation wizard. I would be interested in seeing an example of this, if anyone has one. I am using CCS 1.0.6, PHP 4.0.
Thanks in Advance!!
|
|
|
 |
Per
|
| Posted: 02/08/2003, 12:27 PM |
|
I did a list like that with a heavy workaround.
Now that I have used this program for a while I would go for two grids and link items in each grid. When you click the link for a row, you link to the same page, passing a parameter if necessary, and then execute necessary SQL, moving item from one table to another, on the tables in an Before Select event.
I have just done this, moving from one page to another, but I don't see that it would not work pointing to the same page.
Per
|
|
|
 |
Ken
|
| Posted: 02/08/2003, 4:32 PM |
|
Here is what I want to do in a JavaScript. Try this out so you understand what I am trying to do. Is there any way to convert this to CCS?? So the first list box can be read from a database?
I also thought it would be okay if I could move from a list box to a textarea field. I only need to move one way and this example moves both ways.
Thanks in advance!
HEAD CODE
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
function move(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options.selected && fbox.options.value != "") {
var no = new Option();
no.value = fbox.options.value;
no.text = fbox.options.text;
tbox.options[tbox.options.length] = no;
fbox.options.value = "";
fbox.options.text = "";
}
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}
function BumpUp(box) {
for(var i=0; i<box.options.length; i++) {
if(box.options.value == "") {
for(var j=i; j<box.options.length-1; j++) {
box.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
}
}
if(ln < box.options.length) {
box.options.length -= 1;
BumpUp(box);
}
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts = box.options;
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options.value = temp_opts.value;
box.options.text = temp_opts.text;
}
}
// End -->
</script>
BODY CODE
<center>
<form ACTION="" METHOD="POST">
<table border="0">
<tr>
<td><select multiple size="5" name="list1">
<option value="11"> item 1.1 </option>
<option value="12"> item 1.2 </option>
<option value="13"> item 1.3 </option>
</select></td>
<td>
<input type="button" value=" >> " onclick="move(this.form.list1,this.form.list2)" name="B1"><br>
<input type="button" value=" << " onclick="move(this.form.list2,this.form.list1)" name="B2">
</td>
<td><select multiple size="5" name="list2">
<option value="21"> item 2.1 </option>
<option value="22"> item 2.2 </option>
<option value="23"> item 2.3 </option>
</select></td>
</tr>
</table>
</form>
</center>
|
|
|
 |
Ken
|
| Posted: 02/08/2003, 7:42 PM |
|
I got this to work using a CCS Multi-Selection Listbox and a Textarea field and a serious modification of the javascript above. The only issue I have to work out now is why the textarea leves a space at the top. I will post all of the details of this on this site: http://www.kabwebs.com/ccsniplets/index.php
This is a great for those wishing to have a list box populate another table.
|
|
|
 |
|