7 Replies - 782 Views - Last Post: 15 March 2011 - 05:46 AM

#1 Kaybin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-August 08

Inherited Javascript App Page - Calculation Display - Need Help

Posted 11 March 2011 - 12:57 PM

Ok Here is the scoop.
I am helping out a client of mine who is inheriting this entire conglomerate website deal. Problem is, this is my first look at the app.

Here it is live right now.
Current Live Form/Script

Here is what I have accomplished so far and need some help with.
In need of some help

What I did - Front End
Added the extra dropdown option called 'Handles' and created function to populate dropdown once a certain other 'Cylinder' dropdown is selected.
What I did - Back End
Created 7 new records in the database with (1 for each handle) and filled in the 12 pricing fields that appply. (at least that I think apply right now) (mySQL database)

What I need help with
Now, when you hit the calculate button, it says there are no entrance systems avail. which is the general error message I believe. Also, I am trying to add a 3rd row to the output of the Calc_butn to display the Part Number , Part Name , Net Price , A Multiplyer option like above row.

First I wanted to at least get the calculate button to display what it has correctly.

Here is the code I have for xt_specifier.php (The Calculate Code)
<?php

	/* THE PURPOSE OF THIS FILE IS TO FIND A MATCH */

	/* BUILD THE WHERE CLAUSE */
		$where='';
		/* LOOP THROUGH THE SELECT MENUS, EXCLUDING THE "FINISH" AND THE "DOOR TYPE" */
			foreach($_POST AS $key=>$value) {
				if(
					substr($key,0,4)=='sel_'
					&&
					strlen($_POST[$key])>0
					&&
					$key!='sel_14'
					&&
					$key!='sel_0'
				) {
					if(
						substr_count($_POST[$key],'null')==0
					) {
						$where.=' AND '.$key.'_'.$_POST[$key].'="Y"';
					}
				}
			}

		/* THE "DOOR TYPE" EXCEPTION */
			if(
				$_POST['sel_0']!='N/A'
				&&
				$_POST['sel_0']!='null'
			) {
				$where.=' AND sel_0_'.$_POST['sel_0'].'="Y"';
			}
				$where=substr($where,4);
				$where=' WHERE '.$where;

	/* BUILD THE QUERY */
		$query='SELECT * FROM specifier'.$where.' LIMIT 1';

	/* CONNECT TO THE DATABASE */
		mysql_connect('********','******','**********');
		mysql_select_db('****************');

	/* EXECUTE */
		$sql=mysql_query($query);

	/* SET SOME VARIABLES */
		if(mysql_affected_rows()>0) {
			/* GET THE VALUES */
				while($row=mysql_fetch_object($sql)) {
					/* THESE CAN BE DISPLAYED AS TEXT */
						$span_display_dorset_number=$row->door_set_number;
						$span_doc_draw_pdf=$row->doc_draw_pdf;
						$span_doc_spec_pdf=$row->doc_spec_pdf;
						$span_doc_spec_doc=$row->doc_spec_doc;
						$span_doc_draw_dwg=$row->doc_draw_dwg;
						$span_display_handle_number=$row->handle_part;
					/* DETERMINE THE PRICE */
						switch($_POST['sel_14']) {
							case '101':
								$price=$row->price_101;
							break;
							case '108':
								$price=$row->price_108;
							break;
							case '109':
								$price=$row->price_109;
							break;
							case '700':
								$price=$row->price_700;
							break;
							case '701':
								$price=$row->price_701;
							break;
							case '599':
								$price=$row->price_599;
							break;
							case '503':
								$price=$row->price_503;
							break;
							case '600':
								$price=$row->price_600;
							break;
							case '601':
								$price=$row->price_601;
							break;
						}
				}
			/* FOR AJAX */
				echo 'span_display_dorset_number='.$span_display_dorset_number.'&span_doc_draw_pdf='.$span_doc_draw_pdf.'&span_doc_spec_pdf='.$span_doc_spec_pdf.'&span_doc_spec_doc='.$span_doc_spec_doc.'&span_doc_draw_dwg='.$span_doc_draw_dwg.'&price='.$price;
		}
?>


The Handles option is setup as sel_15 on the index form which you can see just by clicking on second link. Any help is greatly appreciated guys. (Java is not my strongest suit)

This post has been edited by Dogstopper: 11 March 2011 - 01:34 PM
Reason for edit:: Sensitive information removed.


Is This A Good Question/Topic? 0
  • +

Replies To: Inherited Javascript App Page - Calculation Display - Need Help

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10462
  • View blog
  • Posts: 38,773
  • Joined: 27-December 08

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 11 March 2011 - 07:42 PM

Since this is PHP, not Java, I'll move it there. :)
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3520
  • View blog
  • Posts: 10,160
  • Joined: 08-June 10

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 11 March 2011 - 10:43 PM

the error message is caused by Javascript.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 12 March 2011 - 05:40 AM

Edited title to reflect that this is a Javascript question, not Java. Knowing what you're working with is the first step in fixing your problems.

I'll move this to Javascript.
Was This Post Helpful? 0
  • +
  • -

#5 Kaybin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-August 08

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 13 March 2011 - 11:05 AM

Thank you guys. Let me take some better looks at the script before I post it this time. Its always a nightmare when you have no idea where anything is.
Was This Post Helpful? 0
  • +
  • -

#6 Kaybin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-August 08

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 13 March 2011 - 11:20 AM

So here is the javascript code. in file form. It is a complete mess, as I learn js to be quite often. Rename to .js

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 15 March 2011 - 04:00 AM

That Javascript code appears to have been run through a minimizer (at least I HOPE no one actually wrote code like that). Do you actually have the original source Javascript? I hope so, because debugging 70K of minimized JS code will be an extremely difficult task for anyone, never mind a newcomer to the language.
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3520
  • View blog
  • Posts: 10,160
  • Joined: 08-June 10

Re: Inherited Javascript App Page - Calculation Display - Need Help

Posted 15 March 2011 - 05:46 AM

that code is not supposed to be debugged or anything, it’s the jQuery minimised library.

did you check that the AJAX call returns successfully?

EDIT:
taken from the manual:

Quote

int mysql_affected_rows ([ resource $link_identifier ] )
Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query associated with link_identifier.


PS. the number of result sets should be tested by SQL’s COUNT() function.

PPS. mysql_fetch_* returns false if there is no more (has never been a) result set to fetch.

PPPS. if your script returns an error state, you have at least an idea what’s going on.

This post has been edited by Dormilich: 15 March 2011 - 06:04 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1