I have a form that has check boxes and a list box. When an item is selected in the listbox, I want to look up the database associated with that item and change the check boxes to checked or unchecked accordingly. If the first item in the listbox is selected, I want to bring up a form for creating a new item. All I have succeeded with so far is creating the page containing the check boxes and listbox and populating the listbox. Every attempt at getting the selected item to do something worthwhile with the 'onchange' event has failed. Any help would be greatly appreciated. See code below:

ExampleForm.php
Code:
<?php
	include_once 'includes/func.inc.php';
	connect();
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>Item Form</title>
	</head>
	
	<body style="width:800px">
		<form name="frm" action="LoadDatabase.php">
			<table>
				<tr>
					<td style="width: 75%">
						Control 1:
						<input type="checkbox" name="Checkbox1" style="width:50px" />
						Control 2:
						<input type="checkbox" name="Checkbox2" style="width:50px" />
						Control 3:
						<input type="checkbox" name="Checkbox3" style="width:50px" />
						Control 4:
						<input type="checkbox" name="Checkbox4" style="width:50px" />
					</td>
					<td>
						<h4 style="margin-bottom:0px">Item: </h4>
						<select id="items" name="items" size="3" style="width:220px" onchange="ChangeControl(this);">
							<option id="item0" value='new'>New Item</option>
							<?php  query() ?>
						</select>
						<?php close() ?>
					</td>
				</tr>
				<tr>
					<td>
						<input name="submit" type="button" value="Submit" />
					</td>
					<td id="note">Change this value</td>
				</tr>
			</table>
		</form>
	</body>
</html>
func.inc.php
Code:
<?php
	include_once 'includes/db.inc.php';
	
	function connect() {
		mysql_connect(DB_HOST,DB_USER,DB_PASS) or die ('Could not connect to the database ' . mysql_error());
		mysql_select_db(DB_NAME);
	}
	
	function close() {
		mysql_close();
	}
	
	function query() {
		$myData = mysql_query("SELECT * FROM items");
		while($record = mysql_fetch_array($myData)) {
			echo '<option id="' . "item" . $record['item_id'] . '" value="' . $record['item_name'] . '">' . $record['item_name'] . '</option>';
		}
	}
?>	

	<script type="text/javascript">
		function ChangeControl(id)
		
		myIndex = id.selectedIndex;
		myValue = id.options[myIndex].value;
		
		{
			if (myValue = "new") 
			{
				//open dialog box for entering in a new Item
                                //I would be happy If I could get this to open a different php file,
                                //one that I would make into a form for creating a new item.

			}
			else 
			{
				//change the check boxes to checked or unchecked by looking up
                                //item in database.               

			}	
		}
	</script>
db.inc.php
Code:
<?php
	define('DB_NAME', 'example');
	define('DB_USER', 'root');		
	define('DB_PASS', '');	
	define('DB_HOST', 'localhost');
?>
example.sql
Code:
-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jul 18, 2013 at 09:29 PM
-- Server version: 5.5.25a
-- PHP Version: 5.4.7

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `example`
--

-- --------------------------------------------------------

--
-- Table structure for table `form_controls`
--

CREATE TABLE IF NOT EXISTS `form_controls` (
  `control_id` int(11) NOT NULL AUTO_INCREMENT,
  `control_1` tinyint(1) DEFAULT '0',
  `control_2` tinyint(1) DEFAULT '0',
  `control_3` tinyint(1) DEFAULT '0',
  `control_4` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`control_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `form_controls`
--

INSERT INTO `form_controls` (`control_id`, `control_1`, `control_2`, `control_3`, `control_4`) VALUES
(1, 1, 0, 1, 0),
(2, 0, 1, 0, 1),
(3, 0, 1, 1, 0),
(4, 1, 1, 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `items`
--

CREATE TABLE IF NOT EXISTS `items` (
  `item_id` int(11) NOT NULL AUTO_INCREMENT,
  `item_name` varchar(50) NOT NULL,
  PRIMARY KEY (`item_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `items`
--

INSERT INTO `items` (`item_id`, `item_name`) VALUES
(1, 'Item 1'),
(2, 'Item 2'),
(3, 'Item 3'),
(4, 'Item 4');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;