This topic is locked

Question On calculating 2 values on the fly

4/22/2011 10:46:07 AM
PHPRunner General questions
F
fawad112 author

Hi,
I have created 3 dependable dropdown boxes and I want to use the value of the last dropdown box for some calculation with another field. I am having problem as the script is calculating the with the link field of the dropdown not with the display field.
Like id the databaseid for the field is 20 and the display value is 5. It is multiplying with 20 not with 5.

Let me know if you need more clarification or want me to upload on the demo accunt.
Also, Is there any way of connecting to databse using the javascipt onload in phprunner. If yes. I can get the value by connecting the to db but I don't know how to connect in phprunner.
Regards



var ctrlPrice = Runner.getControl(pageid, 'pagesreq');

var ctrlQuantity = Runner.getControl(pageid, 'price');

var ctrlTotal = Runner.getControl(pageid, 'tot');
function func() {

if ( ctrlPrice.getValue()!='' && ctrlQuantity.getValue() && !isNaN(ctrlPrice.getValue()) && !isNaN(ctrlQuantity.getValue()))

ctrlTotal.setValue(parseFloat(ctrlPrice.getValue()) * parseFloat(ctrlQuantity.getValue()));

else

ctrlTotal.setValue('');

};

ctrlPrice.on('keyup', func);

ctrlQuantity.on('change', func);



Regards

Sergey Kornilov admin 4/22/2011

You will need to create a separate PHP file that pulls data from the database and then query this file using jQuery get() method from your Javascript code.

Here is the link to the manual and examples: http://api.jquery.com/jQuery.get/
This PHP file needs to be created manually outside of PHPRunner.

F
fawad112 author 4/22/2011



You will need to create a separate PHP file that pulls data from the database and then query this file using jQuery get() method from your Javascript code.

Here is the link to the manual and examples: http://api.jquery.com/jQuery.get/
This PHP file needs to be created manually outside of PHPRunner.


Hi,
Is this for connecting to the DB? or about taking the display value to be used in calculation.
THanks

Sergey Kornilov admin 4/22/2011

You going to need this PHP file to connect to the database.

F
fawad112 author 4/24/2011

Is there anyway I can get the display field instead of link field value.
var ctrlPrice = Runner.getControl(pageid, 'pagesreq');

ctrlPrice.getValue()
Regards

Sergey Kornilov admin 4/25/2011

Fawad,
you need to rephrase your question, not sure I understand what you asking.