Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    hong kong
    Thanked 0 Times in 0 Posts

    passing form variables

    I have a form, in there have a save and delete button, when click delete button, then there will hv a pop up window to ask is really to delete the record or not. and then will return to the form in the main window to do the delete process. I am now stuck in the point that how I can pass the form variable to the pop up wiondow and then back to the form? since i use java script to open the pop up window, the session variable cannot work for it... so any other method?

    my code is like this:

    <script type="text/javascript">
    function CheckDelete() {
    var answer = confirm ("Are you sure you want to delete this record?")
    if (answer) { window.location="delete.php"; } }
    <input type="button" name="Submit2" value="Del" onclick="javascript:CheckDelete()">

  • #2
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts
    Welcome here.

    Since you want to do it with clientsided javascript, you'd beeter have posted it in the javascript forum.

    But ... not all users have javascript enabled (about 11% i've read somewhere) so tey would miss the dialog. It's better to take care of this serversided, with PHP. You can respond with a page where you center a <div> with a form in it. Then you can store all formvalues in there as hidden formfields with the same names as in the initial form, and display the buttons you need (all as submitbuttons with the same name ("action" or so), but with a different value). In the page, you post this 'dialog' to, you then run some code, depending on the value of $_POST['action']. (All formfields are accesable just as if the initial form was posted straigth to this page).

    (Even better but a bit more complex, is posting the form to itself (both the initial form as the dialog form have the pages name in the action-attribute) and then use a hidden formfield to determine the state of the form. Just post back if you would like to try it with such a multi-pupose page.)


    Posting Permissions

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