This topic is locked
[SOLVED]

 How I can trap the content of filename to fill another field on the fly

10/17/2012 8:06:12 AM
PHPRunner General questions
I
igiacchi author

I'm usign PHPrunner 6.2,

In the first field of my table I have a file image and I'm using the filename control.

To complete another field present in the same Add page I need to fill another field with a file name choosed in the first field on the fly.

I'm tried to use the Onload event to trap the content of filename control but I can not.

Have you some solution.

tnx in advance

C
cgphp 10/17/2012

Post your code.

I
igiacchi author 10/17/2012



Post your code.



Hi Cristian, wellcome!

I'm tring to fill on the fly my txt control serialnumber using the data from the first control filename that I have in the same page.

filename is a control to insert an image into a table field and serial is a part of filename with add "0000"

This is into OnLoad event Add page.
var ctrlFN = Runner.getControl(pageid,'filename');

var crtlSN = Runner.getControl(pageid,'serialnumber');
function serial()

{

serial = ctrlFN.getValue();

var createSN = serial.replace(/_.jpg/,"");

ctrlSN.setValue(createSN + "0000");
}
ctrlFN.on('change', serial);

ctrlFN.on('keyup', serial);
In alternative can I use a snipped code with a button to generate my serial ?

C
cgphp 10/17/2012

Enter the following code in the "Javascript onload" event:

$('input#value_filename_1').bind("DOMSubtreeModified",function() {

var text = '';

if($(this).val() !== '[]')

{

var obj = jQuery.parseJSON($(this).val());

var filename = obj[0].name.substring(0,obj[0].name.lastIndexOf("."));

text = filename + '0000';

}

$("input#value_serialnumber_1").val(text);

});
I
igiacchi author 10/17/2012



Hi Cristian, wellcome!

I'm tring to fill on the fly my txt control serialnumber using the data from the first control filename that I have in the same page.

filename is a control to insert an image into a table field and serial is a part of filename with add "0000"

This is into OnLoad event Add page.
var ctrlFN = Runner.getControl(pageid,'filename');

var ctrlSN = Runner.getControl(pageid,'serialnumber');
function serial()

{

serial = ctrlFN.getValue();

var createSN = serial.replace(/_.jpg/,"");

ctrlSN.setValue(createSN + "0000");
}
ctrlFN.on('change', serial);

ctrlFN.on('keyup', serial);
In alternative can I use a snipped code with a button to generate my serial ?


I'm sorry Cristian was an error into a variables crtl instead of ctrl

C
cgphp 10/17/2012

My code is a solution if you are using the new multi upload feature when the "Compatibility mode" option is not checked.