How can I pass php variables from main page to the external php script.

How can I pass php variables from main page to the external php script.

audioperceptionaudioperception Posts: 3Questions: 3Answers: 0
edited June 2015 in Free community support

// Here are the var's refering to the php variables that where previously defined:
var uid = <? echo $uid; ?>;
var casenumber = <? echo $casenumber; ?>;

var editor = new $.fn.dataTable.Editor( {
    "ajax": "jnote/php/table.vekt6_copo_jnote.php",
    "table": "#vekt6_copo_jnote",
    "fields": [
        {
            "label": "Note",
            "name": "note",
            "type": "textarea"
        }
    ]
} );

// Trying to set values to the php variables from the posting page.
Here is the php file:

$date = date_create();
 $timestamp = date_format($date, 'Y-m-d H:i:s');
 
// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Join,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;


// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'vekt6_copo_jnote', 'id' )
    ->fields(
        Field::inst( 'timestamp' )
            ->setValue( $timestamp ),
        Field::inst( 'case_juror' )
            ->setValue( $uid ),
        Field::inst( 'case_number' )
            ->setValue( $casenumber ),  
        Field::inst( 'note' )
    ) ->where('case_number', $casenumber) ->where('case_juror', $uid)
    ->process( $_POST )
    ->json();

Answers

  • jdmorsejdmorse Posts: 8Questions: 1Answers: 1
    edited July 2015

    Did you ever find an answer to this? Currently working with something very similar.

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin

    For Editor, additional values can be sent to the server using ajax.data or preSubmit.

    For DataTables ajax.data or preXhr.

    Allan

This discussion has been closed.