i have the folowing code

 <?php
    $datumeind = date("Y-m-d");// current date

    $datumverleden = strtotime(date("Y-m-d", strtotime($datumeind)) . " -99 year");//current date -99 years

    $datumbegin = date('Y-m-d', $datumverleden);

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

        if($geboorte_datum <= $datumbegin && $inleven_dood == 'In leven' ){
            ?>
    <script type="text/javascript">
    <!--
    var r=confirm("Klik ok als In Leven."); 
    if (r==true)
    ("<?php $inleven_dood = 'In leven'; ?> ")
    else

    ("<?php $inleven_dood = 'Overleden';     }?> ")
    // -->
    </script>

    <?php

            $updatequery = "UPDATE stamboom_dohmen SET inleven_dood='$inleven_dood' WHERE id='$idpersoon'";
            mysql_query($updatequery) or die (mysql_error()); 
            }

    <form action="gegevens_persoon_bewerken.php" method="post" name="myform" enctype="multipart/form-data">

    <div><input type='checkbox' name='overleden' id='overleden' value='Overleden' title='Kies als overleden.'></div>
    <input type="submit" style=" width:100px;"  name="zenden" value="Alles verzenden"/>
    </form>
    ?>

The code

("<?php $inleven_dood = 'In leven'; ?> ")
        else

        ("<?php $inleven_dood = 'Overleden';     }?> ")

between the javascript dosn't work and i don't know wy
The allert box appears
can someone help me to fix it.
Thanks in advice John
Thanks in advice

Recommended Answers

It doesn't work because JavaScript is executed on the client side, and PHP is executed on the server side.

You could try using a normal form to post the confirmation back to the server, of if you want it to function asynchronously, you could use AJAX.

If using AJAX, I'd …

Jump to Post

All 2 Replies

It doesn't work because JavaScript is executed on the client side, and PHP is executed on the server side.

You could try using a normal form to post the confirmation back to the server, of if you want it to function asynchronously, you could use AJAX.

If using AJAX, I'd recommend you consider using a JavaScript framework, e.g. jQuery, to handle the heavy lifting.

You can remove double quotes (") before & after php tag.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.