Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    30
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Javascript in PHP

    Hi, I have a form and I want to display a pop-up before submitting the data.Problem is I cant call confirmation box at onsubmit or onclick event, as pop-up will appear only if no validation errors are there.

    Something like this:
    Code:
    <?PHP if(empty($err_array)){ ?>
    			<script> 
    			var ans = window.confirm('Are you sure you want to submit this form?');
    					if(ans == true){ </script>
    							<?PHP dbInsert($tbl,$insert_array);
                                echo "<div class='alert alert-success'>
                                <button class='close' data-dismiss='alert' type='button'>&times;</button>
                                Data Inserted
                                </div>";
                                unset($_POST); ?>
    					<script>   } </script>
    <?PHP } ?>
    I am trying to do this since long.Is there any solution to display confirmation window like this?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    You cannot mix client-side script with server-side script like that.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •