My form names are all named like ‘home_lst_defect’ or “defect_frm_main”.
How do I cycle through each character to find underscore so I can then trim and use in a method.
Thanks
My form names are all named like ‘home_lst_defect’ or “defect_frm_main”.
How do I cycle through each character to find underscore so I can then trim and use in a method.
Thanks
OK, I have this to get last part of string, having trouble with getting first part.
var x ="home_defect_test"
var div = x.lastIndexOf("_")+1
var y = x.substring(div,x.length)
why do you need to trim the ‘_’ for using in a method?
you can do this:
var myform = 'home_lst_defect'
forms[myform].controller.loadAllRecords() // just an example, do what ever you want to do here....
Hi James,
What Harjo said.
Also when you want to parse a string like that you could use arrays.
var _sForm = "home_lst_defect",
_aForm = _sForm.split("_");
// _aForm[0] gives first part
// _aForm[1] gives second part
// _aForm[2] gives third and last part
_sForm = _aForm.join(""); // make a string again without underscores
I worked out how to do it with a loop but I like the use of arrays.
I did not need to trim the underscores just detect the first word before the first underscore and the last word after the last underscore.
Split will do it. Thanks heaps