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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    echo varialble in confirm box

    The form page has:
    variable is $prop_id (created by a select statement which populates the form)

    The form action currently is:
    <form action="owner_activate_vacantproperty.php?prop_id=<?php echo $prop_id;?>" method="post" enctype="multipart/form-data" name="tenantform" id="tenantform" onSubmit="return confirm_prog1()">

    The script is:
    <script language='JavaScript'>
    <!-- This is for confirm adding a new property -->
    function confirm_prog1()/// confirm_name in form action line
    {
    var yes=confirm('You are about to add a new property $prop_id to the database! \n\n Do you wish to continue? ');
    if (yes)
    return true ;
    else
    return false ;
    }
    </script>

    I am new to this and have tried to google this but cannot find an answer.

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    lik so :

    Quote Originally Posted by azroman1 View Post

    <form action="owner_activate_vacantproperty.php?prop_id=<?php echo $prop_id;?>" method="post" enctype="multipart/form-data" name="tenantform" id="tenantform" onSubmit="return confirm_prog1()">

    The script is:
    <script type="text/javascript">
    <!-- This is for confirm adding a new property -->
    function confirm_prog1()/// confirm_name in form action line
    {
    var yes=confirm('You are about to add a new property <?php echo $prop_id;?> to the database! \n\n Do you wish to continue? ');
    if (yes)
    return true ;
    else
    return false ;
    }
    </script>

  • #3
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you - works like a charm. Thought I had tried that before and did not work...???

    One last question if I may.
    I have many confirm boxes and instead of having the script on each page I put them in a scripts directory in the root.

    So to pass that variable to another page, I am thinking to set up a session on the form page ( $_SESSION['prop_id'] = $prop_id;
    and then echo the session value in the confirm box...

    Will that work?

  • #4
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I answered my own last question re: using a session.
    Again thanks for the help.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 644 Times in 634 Posts
    I think this has been posted in the wrong forum. The original post is asking a question about the old way of debugging scripts - not providing a script to share.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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