This topic is locked
[SOLVED]

 Get Custom Field Value List Page

4/24/2011 4:21:16 AM
PHPRunner General questions
M
macalister author

Hello.
I want to know how to get the value of a custom field on the list page with a button.
I followed the steps of the manual add custom field to form.

  1. Proceed to the Visual Editor page, switch to HTML mode and add a custom input field to your form. Make sure you specify field ID.

<INPUT id=test type=text>


2. Add the following code to Javascript OnLoad event of the page where custom field was added:

this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
var val = $("#test").val();
formObj.baseParams['test'] = val;
});


3. In any event like Before record added or Before process use $_REQUEST["test"] to access the custom field value.in the last step i put $_REQUEST["test"]
In the last step i put $_REQUEST["test"] on the server button properties but nothing happens, the value of the custom text field is not saved.
this is my button server code



global $dal;
foreach($keys as $idx=>$val)
{
$tblName = $dal->Table("suscriptor");
$rstmp = $tblName->Query("id_suscriptor=".$val["id_suscriptor"],"");
$datatmp = db_fetch_array($rstmp);
$sql = "insert into comprobantes_egreso (idbono, id_comprobante) values ('".$datatmp["id_numControlBono"]."', '".$_REQUEST["test"]."')";

CustomQuery($sql);
}


Thanks for your time and help.

Admin 4/24/2011

It won't work this way. You can use $_REQUEST["test"] in server-side events only like 'Before record added' or 'Before process'. This request variable is only populated after form is submitted which is not the case when you use button.
In your case you need to implement button's ClientBefore event to get the value of this field and pass it to button's server code.



ClientBefore:


params["test"] = $("#test").val();
Server:

use $params["test"] to access this value

M
macalister author 4/24/2011

Thanks so much it works perfectly. !!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=57845&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />