SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Getting headach with confirmation script and passing value with type=image button

    Hi,
    I can make a confirmation script redirected to the a page I need with the script bellow, but the variables I want to carry out with it do not pass. How do I solve this problem.

    Code:
    <script type="text/javascript">
    <!--
    	function confirmation() {
    		var answer = confirm("Are you sure you want to delete the item?");
    		if (answer){
    			alert("Removing the item!");
    			window.location = "delete.php";
    			return true;
    		} else {
    			alert("Some items worth keeping!");
    			return false;
    		}
    	}
    //-->
    </script>					
    <form method='post'>
    	<input type='hidden' name='id' value='<?php echo $row['id']; ?>' />
    	<input type='hidden' name='name' value='<?php echo $row['name']; ?>' />
    	<input type='image' src='images/delete.png' onclick='confirmation(); return false' title='delete item' />
    </form>
    Thanks so much

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ketting00 View Post
    but the variables I want to carry out with it do not pass. How do I solve this problem
    Supply the form with an action page, and then use the form's onsubmit event to handle the confirmation process. You can cancel the submission by returning false back to the onsubmit event.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Thanks Paul,

    I get the picture now. Very appreciated.


Bookmarks

Posting Permissions

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