I am trying to make a database of service manuals and have this database easily accessible to myself and others. I would like it to work with a cascading list. After going through the JQuery plugins I found JCombo, which was exactly what I was looking for. I am able to get the code to function properly and access my database with no issues. The only problem I have is viewing and/or downloading the file once I have it selected. I have looked through many forums, and I have yet to find a solution. You can view what I have done so far by going
here
Here's the main code
- <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>jQuery Combo</title>
- <script type="text/javascript" src="script/jquery.js"></script>
- <script type="text/javascript" src="script/jquery.jCombo.min.js"></script>
- </head>
- <body>
- <table>
- <tr><td>Manufacturer</td><td><select name="mfg" id="mfg"></select></td></tr>
- <tr><td>Device</td><td><select name="device" id="device"></select></td></tr>
- <tr><td>File</td><td><select name="file" id="file"></select></td></tr>
- </table>
- <script type="text/javascript">
- $(function() {
- $("#mfg").jCombo("services/getMFG.php", { selected_value : '<?php print($mfg_id); ?>' } );
- $("#device").jCombo("services/getDevice.php?id=", {
- parent: "#mfg",
- parent_value: '<?php print($mfg_id); ?>',
- selected_value: '<?php print($device_id); ?>'
- });
- $("#file").jCombo("services/getFile.php?id=", {
- parent: "#device",
- parent_value: '<?php print($device_id); ?>',
- selected_value: '<?php print($file_id); ?>'
- });
-
- });
- </script>
- <br/>
- <input type="button" id="view" value="View"/>
- <input type="button" id="download" value="Download"/>
- </body>
- </html>
Here's the PHP:
For Manufacturer
- <?php
- // connect database
- include("../config.php");
-
- // execute query in correct order
- //(value,text)
- $query = "SELECT id_mfg, mfg_name FROM mfg ORDER BY mfg_name ASC";
- $result = mysql_query($query);
- $items = array();
- if($result && mysql_num_rows($result)>0) {
- while($row = mysql_fetch_array($result)) {
- $items[] = array( $row[0], $row[1]);
- }
- }
- mysql_close();
- // encode to json
- echo(json_encode($items));
- ?>
For the Device
- <?php
- // connect database
- include("../config.php");
-
- // get id param (from get vars)
- $id = !empty($_GET['id'])?intval($_GET['id']):0;
- // execute query in correct order
- //(value,text)
- $query = "SELECT id_device, device_name FROM devices WHERE id_mfg = '$id' ORDER BY device_name ASC";
- $result = mysql_query($query);
- $items = array();
- if($result && mysql_num_rows($result)>0) {
- while($row = mysql_fetch_array($result)) {
- $items[] = array( $row[0], $row[1]);
- }
- }
- mysql_close();
- // encode to json
- echo(json_encode($items));
- ?>
For the File
- <?php
- // connect database
- include("../config.php");
-
- // get id param (from get vars)
- $id = !empty($_GET['id'])?intval($_GET['id']):0;
- // execute query in correct order
- //(value,text)
- $query = "SELECT id_file, file_name FROM file WHERE id_device = '$id' ORDER BY file_name ASC";
- $result = mysql_query($query);
- $items = array();
- if($result && mysql_num_rows($result)>0) {
- while($row = mysql_fetch_array($result)) {
- $items[] = array( $row[0], $row[1]);
- }
- }
- mysql_close();
- // encode to json
- echo(json_encode($items));
- ?>
Ultimately, I would like to be able to hit "View" and the pdf open in a new window or hit "Download" and have a download box pop-up. Any help will be greatly appreciated...thank you.