I inherited a page on the company website. The page has a PHP text filter and has php code in it calling 2 .js files, that takes appropriate variables and calculates efficiency displayed in a generated pdf.
The entire site is being moved from a WAMP to a LAMP server, and the server location for the .js files had to be changed.

You can test it for yourself at http://fedco-sandbox.com/efficiency-calculator

What happens is the page works like a champ... once. It generates the pdf just fine. If you back button to the previous page, you can change the numbers and it will generate a new pdf with the new numbers.

BUT, there are radio buttons for choosing metric vs US units (just changes postfixes in the form) and pump vs booster calculators. It's the radio buttons that crap out after the first use. After I manually go in and Clear All Caches and refresh the page the radio buttons work again.

On the admin/config/development/performance page no check boxes are checked and both drop menus show

Thanks in advance for ANY help

TBG

Comments

technobrarygeek’s picture

Apparently I was a little too enthusiastic about how well it works... once. The radio buttons don't work even the first time until a Clear All Cache is performed. THEN they work... once.

TBG

marksward’s picture

Looking at the page source (html) it looks at a glance that the radios are outside of the 'form' element wondering if that is intentional?

technobrarygeek’s picture

Mark, thanks for the quick help.

I hadn't noticed that. As I said I inherited this site and this code. I moved the radios inside the form element and it had no effect on the problem at hand.

Thanks again,
TBG

technobrarygeek’s picture

Here's a little more info on what's going on.

In a small php hunk at the beginning of code it's using drupal_add_js(drupal_get_path('module', 'my_module') to lode 2 .js files. One has all math to do the efficiency calculations. The other is an array of conversion variables and values. It appears the radios buttons are passing a value for a variable in the first js file that selects metric vs us and/or pump vs booster.

It seems that the variable used by the js in the first run through isn't cleared out until caches are cleared. Is there some way to clear them programmatically at the end?

Couldn't do it without you all (I'm just not that smart lol)

TBG

technobrarygeek’s picture

Ok I have determined that what is causing trouble is the 'onclick' part of input commands. Like:

<div style="float: left;">
				<input type="radio" name="units" onclick="updateunits('m');" CHECKED> Metric Units<br>
				<input type="radio" name="units" onclick="updateunits('u');"> US Units
			</div>
			<div style="float: left; margin-left: 10px;">
				<input type="radio" name="calc" onclick="on('peff'); off('beff');" CHECKED> Pump Efficiency Calculator<br>
				<input type="radio" name="calc" onclick="off('peff'); on('beff');"> Booster (turbocharger) Efficiency Calculator
			</div>

			<div style="clear: both;"><br>

I'm getting a bit over my head here, but is the "clear: both" supposed to be resetting these or is it just for the float stuff?

And what do these have to to do with Drupal cacheing?

TBG

marksward’s picture

Yup clear:both is just a visual (CSS) thing not affecting the function of the form.

technobrarygeek’s picture

The form works just fine... actually it's the swapping of metric vs British units and/or pump vs booster that's only working once. It looks like onclick="on('peff'); off('beff');" CHECKED> is making the peff (pump efficiency) div visible on load and the beff (booster efficiency) div hidden. The other radio button switches them onclick="off('peff'); on('beff');"> beff on and peff off. Similar strategy for the units.

This is the operation that doesn't function until I Clear All Caches in Drupal even upon first load, and after each use. If I use the form once then back button to it I can change the numbers in the fields and rerun it and it works. As, long as I don't need to change units or from pump to buster or visa versa.

What I'm still trying to figure is how/why this is involved in Drupal cacheing.

TBG

marksward’s picture

As a thought is it Drupal caching (as in on server) or browser caching.

Easiest way is to try 2 different browsers.

marksward’s picture

You have a javascript error each time the radio button is selected (changing from metric to US):

Uncaught ReferenceError: updateunits is not definedonclick @ efficiency-calculator:192
efficiency-calculator:191 Uncaught ReferenceError: updateunits is not definedonclick @ efficiency-calculator:191

My hunch is your javascript isn't being included, do you know the name of the javascript file that contains the updateunits function?

technobrarygeek’s picture

I have cache deactivated on my Firefox and have tested it in IE and Chrome with the same results.

updateunits is in the effcalc.js file.

It does appear that the js files aren't being included until I 'Clear All Caches' in Drupal.

There are a couple of things I didn't think to mention before. This is an updated direct copy of the live website. It's an update from Drupal 7.0 to 7.4x The 7.0 version is live and sits on a WAMP server internally. The new one is on a remotely hosted LAMP server. The Eff. Calc. works like a champ on the WAMP version.

There is also another 'page' like this that requests a quote from our sales dept. It has a couple of drop downs where "Other" is a choice and when you select "Other" a text box appears for you to describe what "Other" is. This "Other" text box doesn't appear until after a Clear All Cache as well.

I GREATLY appreciate your time Mark. You have no idea.

TBG

technobrarygeek’s picture

In the original version I inherited the js files are included like this:

<?php
drupal_add_js(drupal_get_path('module', 'my_module') . 'sites/all/blah/blah_includes/effcalc/effcalc.js');
drupal_add_js(drupal_get_path('module', 'my_module') . 'sites/all/blah/blah_includes/effcalc/convert.js');
?>

which I replaced with:

<script type="text/javascript" src="sites/all/blah/blah_includes/effcalc/effcalc.js" ></script>
<script type="text/javascript" src="sites/all/blah/blah_includes/effcalc/convert.js" ></script>

outside of Drupal and php and VOILA it works.

Now to see how to rework the other page.

Thanks Mark I couldn't have done it without you.

TBG

technobrarygeek’s picture

BOTH files are now loading their respective js files.

Drupal community ROCKS!

TBG

marksward’s picture

glad you got it sorted!

The paths in the non-working version look wrong to me. Normally you would create say a 'js' folder inside your module so the path would be the path to your module /js/myjavascriptfile.js

technobrarygeek’s picture

Mark,

These were/are, hard coded inside a basic page node, forms to either generate a pdf or send an email. Looks like someone before me was treating Drupal more like Dreamweaver than a CMS. lol

I'm getting it all ironed out.

TBG

david852’s picture

This is actually the first time I am commenting on an article online.I found this to be very clear, informative and precise. It was an easy read and it definitely helped me to understand how the manifest file works. Great job!

david852’s picture

This is actually the first time I am commenting on an article online.I found this to be very clear, informative and precise. It was an easy read and it definitely helped me to understand how the manifest file works. Great job!

david852’s picture

This is actually the first time I am commenting on an article online.I found this to be very clear, informative and precise. It was an easy read and it definitely helped me to understand how the manifest file works. Great job!

david852’s picture

This is actually the first time I am commenting on an article online.I found this to be very clear, informative and precise. It was an easy read and it definitely helped me to understand how the manifest file works. Great job!