[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Move Items between select boxes

Posted on 2003-11-22
1
Medium Priority
?
310 Views
Last Modified: 2012-08-13
I have two select boxes.  The first is populated from PHP:

$query="SELECT page_permissions.page_id,pages.page_name FROM page_permissions INNER JOIN pages ON page_permissions.page_id = pages.page_id WHERE page_permissions.user='" . $_SESSION['username'] . "'";

$result1 = mysql_query($query);
while($row = mysql_fetch_array($result1))
{
    $toprint="<option value=\"$row[page_id]\">$row[page_name]\n";
    print($toprint);
}


What I want to do is have two buttons, a "->" that will place the selected element from the first box into the second box and "<-" that will remove the item selected in the second box.  Then, once the user is done adding elements into the second select box, I want to INSERT those values into my MySQL database using PHP.  I have been strugging with this for about 8 hours now and realized it was time to ask for help.  I'm having all kinds of issues with this (I can't get multiple 'submit' buttons to work without reloading the page wrong, etc.).  Basically, I'm starting out in this and it's my first web development experience and it's not treating me well.  I realize this is a question with a huge scope, so I made it worth alot of points and I can split them if you dont' have time to answer all the issues right at once.

Thanks ahead of time for your help.

Chad
0
Comment
Question by:mistaeverly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
lozloz earned 1000 total points
ID: 9806301
first you want to be doing this through javascript i think:

http://javascript.internet.com/forms/form-swapper-2.html

that seems to be the script you want. all you want to do there is replace the name="list1" for name="items[]", replace all the options with your PHP query above, and have a submit button point to a page to do the processing. then your processing page (could be the same page) will just do:

foreach($_POST["items"] as $key => $val) {
  $query = "INSERT INTO table (column1, column2) VALUES ('$key', '$val')";
  $result = mysql_query($query) or die(mysql_error());
}

if you need any more help then ask away

loz
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question