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?

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?

 

  Quote

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.