user1722138
user1722138

Reputation:

How to insert database cell data into javascript alert

I have a simple form, when users submit the form, after successful validation, they get an alert

if (valid) {
    alert("Your Request Has Been Submitted")
} 
return valid;`

My goal is to have an auto incremental ticket number displayed in the javascript alert, I realize this can only happen after the data has been posted to the db, and that this can easily be done by sending the user to another page, but I'd like to have the page refreshed, and have an alert popup giving them a ticket number, then they can close the alert box and make another submission. Any assistance is appreciated. THANKS!!!

Upvotes: 1

Views: 497

Answers (2)

dinox0r
dinox0r

Reputation: 16039

You can do something like:

<script>
    var valid = <?php echo $query_result; ?>;
    if (valid) { alert("Your Request Has Been Submitted") }return valid;
</script>

Ensure that you PHP code echo'es a valid javascript for the value of the valid variable

Upvotes: 0

Russell Gutierrez
Russell Gutierrez

Reputation: 1385

I recommend you start reading about AJAX

Upvotes: 2

Related Questions