Link to home
Start Free TrialLog in
Avatar of BrighteyesDesign
BrighteyesDesignFlag for Afghanistan

asked on

compulsory details box before viewing website

I need to create the following function:

When a user navigates to to the website whenever they try to click on anything a box appears asking for standard details such as name, phone and email. Once the user has submitted this form the box disappears and they can then navigate around the site.

Is this possible? either with Javascript or PHP?
Avatar of Bardobrave
Bardobrave
Flag of Spain image

How will you manage following visits of a user that has sent contact data already?
Avatar of BrighteyesDesign

ASKER

HI Bardo,

I asked my client that.

As soon as someone submits the details my clients calls them and they have no need to visit the site again.

It's basically a temporary microsite to generate leads.
Avatar of Dave Baldwin
You're talking about a 'login'.  There are lots of them using javascript and PHP.
No strictly.

It's kind of a cross between a login and a form.

There's no usernames or passwords involved. The form need to collect data such as name, phone and email then send this info to a recipient (my client) when they press submit.

I'm fine with creating logins what i'm not sure about is how to present this form when a user clicks anywhere on the screen and then disappear when they have filled in and submitted their details
Sounds annoying to me, but that is just my opinion...

I would set a session variable when the form data is processed. You could then check this session variable before outputting the regular page, and if it is not set, display the form instead.
Here's an image which may help to explain further what I am trying to achieve.
login.jpg
If the session var is not set, display a transparent div that is absolutely positioned to fill the entire screen. The form is in the middle of this div. Anything behind the div would be inaccessable.

As for clicking first, is there any point? why not just display the form straight off?
That's my opinion too but I need to pay the mortgage and it's what my client wants!

It doesn't matter about remembering the session by the way, this form can show every time.

What I need to know is....

1) How to present the form (as per the image in my last message) whenever anyone tries to click anywhere on the screen.

2) On submit the form disappears and the website can be viewed as normal.

I sent that before your last response by the way!
Avatar of Proculopsis
Proculopsis


For what it's worth, here is a trivial example:

<html>

<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q__26638969.html</title>
</head>

<script>
var authorised =  false;

function ifAuthorised( uri )
{
  if ( !authorised ) authorised = confirm( "Simulate authorisation\n\rClick OK for sucsess" );
  if ( authorised ) document.location.replace( uri );
}
</script>

<body>

<a href="javascript:ifAuthorised('http://goggle.com')">Try Me!<a/>

</body>
</html>

Open in new window

Showing the webpage first would allow an initial impact to be created and that first click would express an interest.

The full screen div makes sense it's just how to show it when the user clicks

CAUTION: my typo above upsets my anti-virus software, of course it should be "google".
Thanks Proculopsis!

Not what i'm after though. There needs to be a registration form on the click and the pop up needs to show as per my earlier attachment.
ASKER CERTIFIED SOLUTION
Avatar of ollyatstithians
ollyatstithians
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect, that'll do the trick!!!

Thanks a lot.
There were a couple of problems with my solution, here is a fixed one:
<?php session_start(); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Obtrusive form demo</title>
<meta http-equiv="content-type" content="text/html">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<style type="text/css">
	#formcontainer
	{
		position: fixed; width: 100%; height: 100%; top: 0; left:0; 
	}
	#mask
	{
		width: 100%; height: 100%; background: white; opacity: 0.5; filter:alpha(opacity=50); /* This is the div that covers the content */
	}
	#formcontainer form
	{
		background: white; border: 0.2em double black;
		position: absolute; height: 10em; width: 10em; top: 50%; left: 50%; margin-top: -5em; margin-left: -5em; /* Centers the form on the screen */
	}
</style>
</head>
<body>
<h1>Normal page content</h1>
<p><a href=".">A link.</a></p>
<h3>The standard Lorem Ipsum passage, used since the 1500s</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<h3>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h3>
<p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>

<h3>1914 translation by H. Rackham</h3>
<p>"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<h3>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h3>
<p>"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<h3>1914 translation by H. Rackham</h3>
<p>"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<?php
if(isset($_GET['hideform'])) // this should be a form control (I have used GET so you can see it)
{
	// Test here that the form data is OK and set the session var
	$_SESSION['hideform'] = true;
}
elseif(!isset($_SESSION['hideform']))
{
?>
<div id="formcontainer" onclick="setOpacity(this, 1);">
	<div id="mask">
	</div>
	<form method="get" action="index.php">
		<p><input type="submit" name="hideform" value="Hide form"></p>
	</form>
	<script type="text/javascript">
		function setOpacity(element, opacity)
		{
			element.style.opacity = opacity; // Set opacity for Firefox...
			element.filters.alpha.opacity = opacity * 100; // ... and IE
		}
		setOpacity(document.getElementById('formcontainer'), 0);
	</script>
</div>
<?php
}
if(isset($_GET['reset'])) unset($_SESSION['hideform']);
if(isset($_SESSION['hideform'])) 
{
	var_dump($_SESSION['hideform']);
}
else
{
	echo ('Unset');
}

?>
</body>
</html>

Open in new window


I think this is the sort of effect you are after:

<html>

<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q__26638969.html</title>

<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>

<style>
#login
{ width: 300px; height: 150px; background: white; border: 1px solid black; text-align: center; position: absolute; margin-left: -150px; margin-top: -75px; left: 50%; top: 50%; z-index: 20; display: none;
 background-color: beige; }
</style>

<script>
var overlayOpacity = 0;

function overlayRefresh()
{
  $("#grey-overlay").css({"opacity":overlayOpacity,"width":$(document).width(),"height":$(document).height(),"position":"absolute",
"left":0,"top":0,"background":"black"});
}

$(function(){
  $(window).resize( overlayRefresh );

  $("#tryme").click(function(){
    overlayOpacity = 0.7;
    overlayRefresh();
    $('#login').css({"display": "block"});
    $('#grey-overlay').css({"display": "block"});
  });

  $("#register").click(function(){
    overlayOpacity = 0;
    overlayRefresh();
    $('#login').css({"display": "none"});
    $('#grey-overlay').css({"display": "none"});
  });

});
</script>

</head>

<body>

<div id="grey-overlay"></div>
 
<input id="tryme" type="button" value="Try Me!" />
 
<div id="login">
Please fill in and submit your details <br />
Name <input type="text" /> <br />
Phone <input type="text" /> <br />
Address <input type="text" /> <br />
<input id="register" type="button" value="Register" />
</div>

</body>
</html>

Open in new window