This topic is locked
[SOLVED]

 create fullname from first and last name

4/18/2019 12:13:13 AM
PHPRunner General questions
S
stanbar1 author

Hi i have a problem i have field firstname field lastname and field fullname. how can i add on load first and last name to fullname...Thank you

woodey2002 4/18/2019
J
jacques 4/18/2019

try concat with mysql

S
stanbar1 author 4/18/2019



Hi i have a problem i have field firstname field lastname and field fullname. how can i add on load first and last name to fullname...Thank you



i add to javascript on load:

var ctrlFullname = Runner.getControl(pageid, 'Fullname');

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

function func() {

ctrlFullname.setValue (ctrlFirstName.getValue()) +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);
Still don't work

woodey2002 4/18/2019
var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

var ctrlFullName = Runner.getControl(pageid, 'FullName');

function func() {

ctrlFullName.setValue((ctrlFirstName.getValue())+(" ") +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('change', func);

ctrlLastName.on('change', func);

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);
M
MikeT 4/18/2019



Hi i have a problem i have field firstname field lastname and field fullname. how can i add on load first and last name to fullname...Thank you


You could also create a calculated field at the database-level (my preferred method) and then load it like any other field of the table. Don't remember if you can create these from phpr, otherwise create it in phpMySQL or any other db-management tool that works with your database.

admin 4/19/2019



var ctrlFullname = Runner.getControl(pageid, 'Fullname');

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

function func() {

ctrlFullname.setValue (ctrlFirstName.getValue()) +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);


Something like this will work. Check for Javascript errors if any. Check this:

https://xlinesoft.com/phprunner/docs/troubleshooting_javascript_errors.htm

S
stanbar1 author 4/19/2019



You could also create a calculated field at the database-level (my preferred method) and then load it like any other field of the table. Don't remember if you can create these from phpr, otherwise create it in phpMySQL or any other db-management tool that works with your database.


var ctrlFullname = Runner.getControl(pageid, 'Fullname');

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');
function func() {
ctrlFullname.setValue(+ctrlFirstName.getValue()*+ctrlLastName.getValue());
};
ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);
It didn't give any errors, but it's still don't work

woodey2002 4/19/2019

This code works!
Test it out

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

var ctrlFullName = Runner.getControl(pageid, 'FullName');

function func() {

ctrlFullName.setValue((ctrlFirstName.getValue())+(" ") +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('change', func);

ctrlLastName.on('change', func);

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);
S
stanbar1 author 4/20/2019



This code works!
Test it out

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

var ctrlFullName = Runner.getControl(pageid, 'FullName');

function func() {

ctrlFullName.setValue((ctrlFirstName.getValue())+(" ") +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('change', func);

ctrlLastName.on('change', func);

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);



i add this code event add page on java script onload event..Don't work

woodey2002 4/20/2019

Check the field names or something as it works for me in the sample add page I tested it on.
Here is SQL...
SELECT

id,

Fullname,

FirstName,

LastName

FROM test
This code works for me on the add page...

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

var ctrlFullName = Runner.getControl(pageid, 'FullName');

function func() {

ctrlFullName.setValue((ctrlFirstName.getValue())+(" ") +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('change', func);

ctrlLastName.on('change', func);

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);
S
stanbar1 author 4/20/2019



Check the field names or something as it works for me in the sample add page I tested it on.
Here is SQL...
SELECT

id,

Fullname,

FirstName,

LastName

FROM test
This code works for me on the add page...

var ctrlFirstName = Runner.getControl(pageid, 'FirstName');

var ctrlLastName = Runner.getControl(pageid, 'LastName');

var ctrlFullName = Runner.getControl(pageid, 'FullName');

function func() {

ctrlFullName.setValue((ctrlFirstName.getValue())+(" ") +

(ctrlLastName.getValue()));

};

ctrlFirstName.on('change', func);

ctrlLastName.on('change', func);

ctrlFirstName.on('keyup', func);

ctrlLastName.on('keyup', func);



Thank it works..when i create separate table it works, but when i try to add to my working table it won't..What something wrong with project?