This topic is locked
[SOLVED]

 javascript incompatibility

10/24/2011 9:51:25 AM
PHPRunner General questions
F
Francesco_5000 author

hi,
I've noticed that this script here: http://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm is compatible only with internet explorer (and don't works with Firefox 7.0.1 and Chrome 14.0.835.202 m ), i'm wondering if you can suggest me a more compatible code that does the same operations.

C
cgphp 10/24/2011

It works fine in Firefox 7.0.1 Check your fields name.

F
Francesco_5000 author 10/24/2011



It works fine in Firefox 7.0.1 Check your fields name.


i've even tried to restart Firefox with the add-ons disabled but the script don't works. Here is the code:


var ctrlindiceFar = Runner.getControl(pageid, 'indiceFar');
var ctrlindiceFrr = Runner.getControl(pageid, 'indiceFrr');
var ctrlindiceErr = Runner.getControl(pageid, 'indiceErr');
var ctrlindiceGar = Runner.getControl(pageid, 'indiceGar');
function func() {
if ( ctrlindiceFar.getValue()!='' && ctrlindiceFrr.getValue() && !isNaN(ctrlindiceFar.getValue()) && !isNaN(ctrlindiceFrr.getValue())) {
ctrlindiceErr.setValue(parseFloat(ctrlindiceFar.getValue()) / parseFloat(ctrlindiceFrr.getValue()));

ctrlindiceGar.setValue(1 - parseFloat(ctrlindiceFrr.getValue())); };
else {
ctrlindiceErr.setValue('');

ctrlindiceGar.setValue('');
};



};
ctrlindiceFar.on('keyup', func);
ctrlindiceFrr.on('keyup', func);


if it's a problem related to the names of the fields why the script works on ie?

C
cgphp 10/24/2011

Do you get some error/exception in the firebug console ?

F
Francesco_5000 author 10/24/2011



Do you get some error/exception in the firebug console ?


yes:


syntax error

[Interrompi per questo errore] var pType=Runner.pages.constants.PAGE_...c);ctrlindiceFrr.on('keyup',func);;});


this is the extended log:



var pType=Runner.pages.constants.PAGE_EDIT;Runner.pages.PageSettings.addPageEvent("tipodispositivo",pType,"afterInit",function(pageObj,pageid){var ctrlindiceFar=Runner.getControl(pageid,'indiceFar');var ctrlindiceFrr=Runner.getControl(pageid,'indiceFrr');var ctrlindiceErr=Runner.getControl(pageid,'indiceErr');var ctrlindiceGar=Runner.getControl(pageid,'indiceGar');function func(){if(ctrlindiceFar.getValue()!=''&&ctrlindiceFrr.getValue()&&!isNaN(ctrlindiceFar.getValue())&&!isNaN(ctrlindiceFrr.getValue())){ctrlindiceErr.setValue(parseFloat(ctrlindiceFar.getValue())/parseFloat(ctrlindiceFrr.getValue()));ctrlindiceGar.setValue(1-parseFloat(ctrlindiceFrr.getValue()));};else{ctrlindiceErr.setValue('');ctrlindiceGar.setValue('');};};ctrlindiceFar.on('keyup',func);ctrlindiceFrr.on('keyup',func);;});var pType=Runner.pages.constants.PAGE_ADD;Runner.pages.PageSettings.addPageEvent("tipodispositivo",pType,"afterInit",function(pageObj,pageid){var ctrlindiceFar=Runner.getControl(pageid,'indiceFar');var ctrlindiceFrr=Runner.getControl(pageid,'indiceFrr');var ctrlindiceErr=Runner.getControl(pageid,'indiceErr');var ctrlindiceGar=Runner.getControl(pageid,'indiceGar');function func(){if(ctrlindiceFar.getValue()!=''&&ctrlindiceFrr.getValue()&&!isNaN(ctrlindiceFar.getValue())&&!isNaN(ctrlindiceFrr.getValue())){ctrlindiceErr.setValue(parseFloat(ctrlindiceFar.getValue())/parseFloat(ctrlindiceFrr.getValue()));ctrlindiceGar.setValue(1-parseFloat(ctrlindiceFrr.getValue()));};else{ctrlindiceErr.setValue('');ctrlindiceGar.setValue('');};};ctrlindiceFar.on('keyup',func);ctrlindiceFrr.on('keyup',func);;});


i know that ie is more fault tolerant than ff, but in the end is only a little modification of the orginal code suggested in the manual.

C
cgphp 10/24/2011

Please, post what firebug says in the Console tab.

F
Francesco_5000 author 10/24/2011



Please, post what firebug says in the Console tab.


i've did it, the two code bloks above are the output of the firebug console

C
cgphp 10/24/2011

Remove any semicolon ; after the closing }

In particular after the closing } of the if statement.

F
Francesco_5000 author 10/24/2011



Remove any semicolon ; after the closing }

In particular after the closing } of the if statement.


ok, now everything works fine but as you can see here: http://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm the original code proposed in the manual have the semicolon after the closing } .

C
cgphp 10/24/2011

Yes, but the ; is after the closing } of the function not of the if statement.