POST doorgeven na div refresh

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

Ferdi R

Ferdi R

15/09/2014 15:15:01
Quote Anchor link
Ik ben niet zo goed met Javascript maar ik heb een heel mooi stukje code die ervoor zorgt dat alleen de div herlaad met resultaten en niet de hele pagina, alleen de POST waardes worden niet doorgegeven.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

    <script type="text/javascript">
    $(document).ready(function(){
        $(function(){
        $('#rekenuit').submit(function(e){
                e.preventDefault();
                var form = $(this);
                var post_url = form.attr('action');
                var post_data = form.serialize();
                $('#uitslag').html('<img src="../../images/ajax-loader.gif" />       Please wait...');
                $.ajax({
                    type: 'POST',
                    url: post_url,
                    data: post_data,
                    success: function(data) {
                        $('#uitslag').fadeOut(800, function(){
                            $('#uitslag').html(data).fadeIn(800).delay(2000);

                        });
                    }
                });
            });
        });
    });
    </script>


Formulier
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php    
    echo '<div class="form">';
        
        // Formulier
        echo '<form id="rekenuit" action="btwberekenen.php" method="post" enctype="multipart/form-data">';

        echo '<ul>';
        echo '<li class="links">Bedrag Excl BTW = </li><li class="rechts"><input type="text" id="bedrag" name="euroe" size="6" maxlength="75" /> <input type="submit" id="exc" name="exc" value="Berekenen" /> ()</li>';
        echo '<li class="links">BTW bedrag ?% = </li><li class="rechts"><input type="text" id="bedrag" name="euror" size="6" maxlength="75" /> <input type="submit" id="btw" name="btw" value="Berekenen" /> ()</li>';
        echo '<li class="links">Bedrag Incl BTW = </li><li class="rechts"><input type="text" id="bedrag" name="euro" size="6" maxlength="75" /> <input type="submit" id="inc" name="inc" value="Berekenen" /> ()</li>';
        echo '</ul>';

        echo '</form>';
        
    echo '</div>';
?>

    <div id="uitslag" class="uitslag"></div>


btwberekenen.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{

    if(isset($_POST['exc']))
    {

        echo 'exc';
    }

    else if(isset($_POST['btw']))
    {

        echo 'btw';
    }

    else if(isset($_POST['inc']))
    {

        echo 'inc';
    }

    else
    {
        echo 'Er is iets fout gegaan.';
    }
}

?>



Steetds staat er als resultaat 'Er is iets fout gegaan'
 
PHP hulp

PHP hulp

19/04/2024 17:52:40
 
Henk de Vriep

Henk de Vriep

15/09/2014 15:46:50
Quote Anchor link
Nevermind, verkeerd gelezen
Gewijzigd op 15/09/2014 15:50:48 door Henk de Vriep
 
Mathieu Posthumus

Mathieu Posthumus

15/09/2014 16:57:36
Quote Anchor link
Kan je ook vertellen wat het is ben wel benieuwd
 
Ferdi R

Ferdi R

15/09/2014 17:39:09
Quote Anchor link
Mathieu Posthumus op 15/09/2014 16:57:36:
Kan je ook vertellen wat het is ben wel benieuwd


Om de BTW te berekenen.

Nu wil ik dat je maar 1 veld kan invoeren en daar heb ik dit stukje code voor gevonden

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
        $('#bedrag').keyup(function() {
            $('#bedrag').siblings().val('')
        })


Maar het werkt niet bij mij.

PS Met de POST heb ik al voor elkaar, ik moest $_POST['euro'] opvangen.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.