Transfer values from one selection box to another
I need to populate the first box with the items from a db table. Users would choose from the first box, and either drag value(items) to the second for selection, or would select items, and then click a button to move them over to the 2nd box. After th开发者_开发知识库at I need to update the db with the selected values/items.
First step: Code a loop to populate the first box with the db values.
Next: Drag&Drop is going to get more complicated than you want if you're just starting out. Depending on the setup, you might be able to do a pretty simple onclick() event to update the second box and not require a button, but to match the behavior you said, point the button to a javascript function which looks at the value set for the first box and then adds them to the second box. There are probably more elegant ways to do this, but just using .innerhtml should work.
Finally: Code the processing page to use update the db based on the values of the second box.
I don't get what the second box is accomplishing in this. Is it like a preview (here's what I'll add to the db if you click submit) type of thing?
精彩评论