Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4340848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:24:17+00:00 2026-05-21T11:24:17+00:00

i.m kind of confuse about this code if($filter_col!=null && $filter_val!=null) $filter = $filter_col.|.$filter_val; $prevpage

  • 0

i.m kind of confuse about this code

if($filter_col!=null && $filter_val!=null)
        $filter = $filter_col."|".$filter_val;      
        $prevpage = $current_page-1;
        printf('<ul class="pagination" style="float:right;">');
    if ( $current_page > 1 ) {       
        echo "<li><a href='#' onclick='loadPage(1,$filter)'>First</a> \n </li>";
        echo "<li><a href='#' onclick='loadPage($prevpage,$filter)'>Prev</a> \n </li>";
    }


function loadPage(page,filter){var dataString;  

dataString = 'page='+ page+'&filter='+filter;  $.ajax({
url: "page_data.php", //file tempat pemrosesan permintaan (request)
type: "GET",
data: dataString,
    success:function(data)
    {
        $('#divPageData').html(data);
    }});}

when i fill the $filter with any string as well as empty string for example ‘oke’ then it has an error said oke is not defined, but when i fill $filter fit any number it works well
can anyone help me? thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:24:18+00:00Added an answer on May 21, 2026 at 11:24 am

    When you fill in a php var like $filter, then insert it verbatim into Javascript, you have to make sure that it becomes valid javascript. e.g:

    $filter = 'oke';
    $prevpage = 1;
    
    ... onclick='loadPage($prevpage,$filter)' ...
    

    will become

    ... onclick='loadPage(1,oke)' ...
    

    which is not valid Javascript, as there is no variable named ‘oke’ in your script. You have to do one of the following:

    $filter = json_encode('oke');
    $prevpage = json_encode(1);
    

    which turns your PHP variable values into native javascript values, or at bare minimum surround the variables with quotes in the javascript part of your code:

    ... onclick='loadPage(\'$prevpage\', \'$filter\')' ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am kind of confused about how the below code works. In my head
I'm kind of confused about reserved words in Ruby. The Ruby Programming Language, co-authored
I'm a noob in python. I'm kind of confused about how the python unit
I have always been kind of confused by threads, and my class right now
Pretty new to all this, so if I am going about my puzzle in
I'm really confused about this, tried to read a lot about diagrams but I
I have several questions about best use of exceptions in Java. Consider the code
Wikipedia says it's called a quine and someone gave the code below: char*s=char*s=%c%s%c;main(){printf(s,34,s,34);};main(){printf(s,34,s,34);} But,
I've always programmed in Java, which is probably why I'm so confused about this:
This question is about the extent to which it makes sense unit testing. I’ve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.