Jump to content

Not sure if this is / can be done php based?


MSUK1

Recommended Posts

I have a form that submits to a page

 

when the user presses the submit button i want the form to wait 3 seconds before submitting (in this 3 seconds a div will slideup using jquery

 

then the form will submit after the nice fancy removal of the div

 

this is probably the wrong way to go about it? but its all i can think?

Link to comment
Share on other sites

i completely re-thought about what i wanted- apologies

 

I used AJAX to process the form to a php page.

 

and as soon as the form was successfully completed the form in the div should hide.

 

Tested and working this is my code: is the formatting okay?

 

I don't see how this relates to php at all. You already said your using jQuery.

 

It related to php because i wanted to process the php form using ajax

 

 

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>EU Cookie Plugin</title>
<style>
div.divvy {width:100%;height:auto;border-bottom:#000;background-color:#333;color:#fff;padding:10px;text-align:center;top:0px;}
</style>
</head>

<body style="padding:0px; margin:0px;">


<? if (!isset($_COOKIE["EURegulationsMSUK"])) { ?>
    <div id="note" class="divvy">
        <form name="setform" method="post" action="setcookie.php">
            <input type="button" id="EUclose" class="button" name="set" value="on" />
        </form>
    </div>
<script>
	$(".button").click(function() {
		var set = $("input#EUclose").val();
		var dataString = 'set='+ set;
	  
	$.ajax({
		type: "POST",
		url: "setcookie.php",
		data: dataString,
	success: function() {
		$('#note').slideUp(400,function () {
			$('#note').remove();
					});
				}
			});
		return false;
	});
    </script>

<? } ?>

    <div>
	<?php
          if (isset($_COOKIE["EURegulationsMSUK"])) 
          echo "Cookie Permission " . $_COOKIE["EURegulationsMSUK"] . "!<br />";
        else
          if(!isset($_COOKIE["EURegulationsMSUK"]))
            echo "Cookie Permission off";
        else
            echo "Error no cookie Set";
        ?>
    <br />
        <p style="display:inline;">Switch off Cookie</p>
            <form style="display:inline;" name="setform" method="post" action="setcookie.php">
                <button name="set" type="submit" value="off">Off</button>
            </form>
    </div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.