Quantcast
Viewing all articles
Browse latest Browse all 30322

JAVASCRIPT Change Variable in PHP through JS and show the additional content

Hello everyone

I have a question concerning js and php.

My idea: I have a div Box like this

Titel
-----------------------
News Object 1
-----------------------
News Object 2
-----------------------
News Object 3
-----------------------
News Object 4
-----------------------
News Object 5
-----------------------
Show more news


the news are called by this code (through ssi from simplemachineforums)

PHP Code:

<?php ssi_ErecentTopics($num_recent 5$exclude_boards null$include_boards 3$output_method 'echo'); ?>
so the whole div box looks like this

PHP Code:

    <div id="stream" class="bg4 roundedcrop shadow">
     <div class="ph25 pv20">
      <h1>News</h1>
      <input id="streamcnt" name="streamcnt" type="hidden" value="" />
     </div>
     <div id="streamadd"></div>
     <div id="streaminner">
<?php ssi_ErecentTopics($num_recent 8$exclude_boards null$include_boards 2$output_method 'echo'); ?>
     </div>
     <div onclick="getStreamMore('',0);" id="streammore">More News articles</div>
    </div>

So i want now for EVERY onclick "Show more news" the variable "$num_recent" increase by 5 and output immediately the news in the div box

This is a variant i managed to do for testing but there are two problems. First I have no plan how to define the var for a php variable (var $n = "<?= $test ?>";). Second I am not sure if the result will show without a reload of the div.


PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>PhpFiddle Initial Code</title>

<script type="text/javascript" src="/js/jquery/1.7.2/jquery.min.js"></script>

<link href="/js/jquery_ui/1.9.1/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery_ui/1.9.1/jquery-ui.min.js"></script>

<script type="text/javascript" src="/js/jquery_validation/1.10.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="/js/jquery_validation/1.10.0/additional-methods.min.js"></script>

<script type="text/javascript">
$(function(){

});
</script>

<style type="text/css">
    
</style>

</head>

<body>

        <input type="text" value="1" id="number"/>
        <input type="button" id="increment" value="Increment"/>

<?php

$test 
0;
    echo 
$test;
?>
<script>
$(document).ready(function(){
    $("#increment").click(function(){
        var $n = "<?= $test ?>";
        $n.val(Number($n.val())+5);
    }); 
});

</script>

</body>
</html>


So here comes you. May you help me giving advice how to solve my problems?


Greetings moere

Viewing all articles
Browse latest Browse all 30322

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>