This topic is locked
[SOLVED]

 5.1 to 5.2 javascript

8/6/2010 4:42:25 AM
PHPRunner General questions
G
garethp authorDevClub member

Hi
I am trying to migrate to 5.2 in preparation to 5.3 &6.0.
I have the followoing Javascript in 5.1 that I jsut can not work out how to change into 5.2 coding for the JavaScript OnLoad event

AddScript2Postload("

document.forms.editform.value_part.onchange=function()

{

document.forms.editform.value_description.value='USE FOR MISC ONLY';

if( document.editform.value_part.value=='MISC')

document.forms.editform.value_description.disabled=false;

else

{

document.forms.editform.value_description.disabled=true;

document.forms.editform.value_description.value='xxx';

}

}
document.forms.editform.value_net_value.disabled=true;

var vv = document.editform.value_unit_price;

var ww = document.editform.value_quantity;

vv.onchange = vv.onkeyup =ww.onchange = ww.onkeyup =function() {

var qty = document.editform.value_quantity.value;

var unit = document.editform.value_unit_price.value;

document.editform.value_net_value.value =parseFloat(qty)*parseFloat(unit);}");


Can you help as this is doing my head in!
Many thanks
Will 5.3 and 6.0 be the same as 5.2 coding?
Gareth

A
ann 8/6/2010

Gareth,
you can just change the names of controls (editform to editform1, value_fieldname to value_fieldname_1).

Please check also the manual on how to use JavaScript API:

http://xlinesoft.com/phprunner/docs/javascript_api.htm

Here is a sample code for the JavaScript Onload event on the Events tab:

var ctrl_d = Runner.getControl(pageid, 'description');

var ctrl_p = Runner.getControl(pageid, 'part');
function func() {

ctrl_d.setValue('USE FOR MISC ONLY');

if (ctrl_p.getValue()=='MISC'){

ctrl_d.setDisabled();

}

...

};



ctrl_p.on('change', func);



We do not plan to make any changes with Javascript coding.

G
garethp authorDevClub member 8/6/2010

Hi Ann
Loving the API. This is great.
Sorted with your help - many many thanks
Gareth