Solved

compulsory details box before viewing website

Posted on 2010-11-25
18
312 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:BrighteyesDesign
  • 8
  • 4
  • 3
  • +3
18 Comments
 
LVL 19

Expert Comment

by:Bardobrave
ID: 34213398
How will you manage following visits of a user that has sent contact data already?
0
 

Author Comment

by:BrighteyesDesign
ID: 34213434
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.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 34213441
You're talking about a 'login'.  There are lots of them using javascript and PHP.
0
 

Author Comment

by:BrighteyesDesign
ID: 34213486
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
0
 
LVL 10

Expert Comment

by:ollyatstithians
ID: 34213498
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.
0
 

Author Comment

by:BrighteyesDesign
ID: 34213509
Here's an image which may help to explain further what I am trying to achieve.
login.jpg
0
 
LVL 10

Expert Comment

by:ollyatstithians
ID: 34213518
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?
0
 

Author Comment

by:BrighteyesDesign
ID: 34213535
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.

0
 

Author Comment

by:BrighteyesDesign
ID: 34213541
I sent that before your last response by the way!
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 20

Expert Comment

by:Proculopsis
ID: 34213571

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

0
 

Author Comment

by:BrighteyesDesign
ID: 34213574
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
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 34213591

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

Author Comment

by:BrighteyesDesign
ID: 34213614
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.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34213943
0
 
LVL 10

Accepted Solution

by:
ollyatstithians earned 50 total points
ID: 34216380
Try this:
<!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>

<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)

{

?>

<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

}

else

{

	// Test here that the form data is OK and set the session var

}

?>

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:BrighteyesDesign
ID: 34216400
Perfect, that'll do the trick!!!

Thanks a lot.
0
 
LVL 10

Expert Comment

by:ollyatstithians
ID: 34216443
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

0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 34216578

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

0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now