in Education by
I have a php file and it contains a textfiled and submit button and a div and below is code Page1.php
You have Entered
if($_POST['submit']) { $v1 = $_POST['email1']; // $query1 = here some code to insert into database if($query1 > 0){ //here i want to display the div `suc_box`.. Here how i can show that div } } And the jQuery code: $(document).ready(function(){ $('suc_box').hide(); $('suc_box').click(function(){ $(this).hide(); }); }); Question: How can I show/display that suc_box when form is submitted after it inserted into database? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can do it easily with AJAX. You have one php-file with the form and another one for processing the data: //form_file.php
$(document).ready(function(){ $('.suc_box').click(function(){ $(this).hide(); }); $('#my_form').submit(function(){ var data = $(this).serialize(); $.post('process.php',data,function(return_data){ $('.suc_box').html(return_data); }); return false; //cancel the 'real' submit }); }); //process.php <?php $email = mysql_real_escape_string($_POST['email1']); //write data to DB if($succeeded) { echo 'You have Entered'; } else { echo 'Something went wrong, try again!'; } It's untested, but you get the idea. validating email field function validateform(){ if (!/^\S+@\S+\.\w+$/.test(document.sweetform.Email.value)) { alert("Not a valid e-mail address"); return false; } else { return true; } }

Related questions

0 votes
    I have a php file and it contains a textfiled and submit button and a div and below is code Page1 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    been working on some database data calling into a .php file. The php file contains an "Add" button ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have Html website. There is newsletter signup form in the html. It is processed by php script file ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I have Html website. There is newsletter signup form in the html. It is processed by php script file ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have Html website. There is newsletter signup form in the html. It is processed by php script file ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have a Bootstrap modal dialog which contains a form. The modal dialog contains a submit and a cancel ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    9. Cancel button (x on formula bar) can be used to undo a cell entry after it has been completed (a) True (b) ... ) Alt+P (d) Ctrl+P Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    I am struggling trying to update a row in an Azure SQL database. What I am trying to do is to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    How can I edit the default Magento contact form to send email with jquery, without quitting the contact ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    How can I edit the default Magento contact form to send email with jquery, without quitting the contact ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    $('#some-table').DataTable({ "language": { "url": "{{ asset('/js/plugins/lang.json') }} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    $('#some-table').DataTable({ "language": { "url": "{{ asset('/js/plugins/lang.json') }} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Hi i'm using this to set a title attribute on elements: $('.upgradeTables thead tr td:gt(1)'). ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    Which hormone is released from pituitary of mother once the foetal development is completed? Select the correct answer from above options...
asked Nov 9, 2021 in Education by JackTerrance
0 votes
    _______ means that data used during the execution of a transaction cannot be used by a second transaction ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
...