You can't combine PHP and JS this way. PHP is executed entirely on the
 server, before Javascript is even parsed.

 From Javascript you need to set something, for instance a special
 value into an <input type="hidden /> in your HTML file. Then, when the
 file is submitted, you need to decide whether to save or not to save -
 and reset the hidden field - if you don't, it will keep the special
 value forever.

 Also, the Javascript as you included it would be executed upon each
 document load, which is probably not what you want. Javascript blocks
 are parsed in order as they are loaded, and anything located outside a
 function definition is executed immediately. In your case, the call to
 confirm is not in a function.

 The snippet you mailed to the list is too small for me to tell you how
 to organize everything. I believe you need to rethink everything,
 since I suppose you expected PHP and Javascript to be executed in the
 same order as you place it in the file. Essentially, you have to keep
 in mind two things: PHP is executed on the server, before anything is
 sent to the browser, and Javascript is executed in the browser, only
 after the entire file was downloaded (provided you don't use included
 Javascript files). And design your interaction around these two
 execution contexts.

Fine counsel is confusing, but example is always clear. (Edgar A.
Guest, The Light of Faith)

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to