Page 1 of 1

PHP in Startup Script

Posted: Thu Aug 01, 2024 4:41 pm
by iggabz

Good day,

i have this custom php function in Client scripts>table specific>add/copy page>startup script

function hideGuellian() {
    $('section div#r_doc_id').hide();
    $('section div#r__action').hide();
    $('section div#r_date_time').hide();
    $('section div#r_office').hide();
    $('section div#r_received_by').hide();
    $('section div#r_prev_datetime').hide();
    $('section div#r_duration_sec').hide();
    $('section div#r_duration').hide();
    $('section div#r_region').hide();
    $('section div#r_province').hide();
    $('section div#r_city').hide();
    $('section div#r_name').hide();
    $('section div#r__email').hide();
    $('section div#r_tracking_no').hide();
    $('section div#r_date_req').hide();

    if (mavg === 'fr') {
        $('section div#r_province').show();
        $('section div#r_name').show();

        if ($_SESSION['CurrentUserLevel'] == 4) {
            $('section div#r_date_req').show();
        }
    } else if (mavg === 'rr') {
        $('section div#r_province').show();
        $('section div#r_name').show();
    }
}

line 22 is not working. is my syntax correct?


Re: Syntax not executed

Posted: Thu Aug 01, 2024 4:48 pm
by arbei

You cannot mix PHP code ($_SESSION['CurrentUserLevel']) into JavaScript directly, you need to echo it out by PHP.


Re: PHP in Startup Script

Posted: Thu Aug 01, 2024 4:54 pm
by iggabz
var currentUserLevel = <?php echo $_SESSION['CurrentUserLevel']; ?>;

got this. thank you. i used the line to get the session value