Question

HTML form preview

Asked by: l_starter_l

HI,
I need an HTML form preview script.. When a user clicks submit a pop-up should come up with the information the user entered in the form. I would also like when the window pops up the background dims.. Does anyone have a script that can do this??

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-15 at 10:26:14ID24815634
Tags

HTML

,

javascript

,

jquery

Topics

Hypertext Markup Language (HTML)

,

Jquery

,

JavaScript

,

Web Languages/Standards

Participating Experts
3
Points
500
Comments
24

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Html preview
    Hi! I need a simle sample program which shows preview of html file using webbrowse, Exlorer, dhtml or something like taht. Can anybody help me with it?
  2. Print a Previewed Report
    When I print preview a report, it is OK. When I click the print button, the report loses focus and what was a backfground form, prints instead of my report. Help please

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: jagadeesh_motamarriPosted on 2009-10-15 at 11:16:45ID: 25583216

 

by: l_starter_lPosted on 2009-10-15 at 11:38:50ID: 25583433

That's not what I'm lookinf for..I want a form preview with no  images.. Preview the text fields..

 

by: Terry_focusPosted on 2009-10-15 at 11:54:47ID: 25583571

When the background dims is called a modal window, I use jQuery UI for this

http://jqueryui.com/demos/dialog/#modal

Your preview script would probably be quite custom, but if you used this modal window to design your preview I can help with the script to populate it with your field values

 

by: l_starter_lPosted on 2009-10-15 at 17:35:57ID: 25586140

Hi,
Can you give me an example of how I would populate an HTML text field element

 

by: Terry_focusPosted on 2009-10-16 at 00:58:34ID: 25587636

Sure

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Example Page</title>
<style type="text/css">
div {
	height:100px;
	border:1px solid #000;
	padding:5px;
	margin:5px;
	width:10em;
}
</style>
<script type="text/javascript" src="jquery-1.3.min.js"></script>
<script type="text/javascript">
$(function(){//On page load attch events
	/**
	*Example A
	*Copy the text from one field to another
	*/
	$("#buttonA").click(function(){
		$("#toA").val($("#fromA").val());//The value (val) of toA = value of fromA
	});
	/**
	*Example B
	*Copy the text from one field to a the innerHTML of another tag
	*/
	$("#buttonB").click(function(){
		$("#toB").html($("#fromB").val());//The innerHTML (html) of toB = value of fromB
	});
})
</script>
</head>
<body>
	<div>
		<input type="text" id="fromA" value="Text A" />
		<input type="text" id="toA"/>
		<input type="button" id="buttonA" value="Example A" />
	</div>
	<div>
		<input type="text" id="fromB" value="Text B" />
		<span id="toB"></span>
		<input type="button" id="buttonB" value="Example A" />
	</div>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:

Select allOpen in new window

 

by: l_starter_lPosted on 2009-10-16 at 08:35:19ID: 25590505

thanks Terry_focus,
I meant an example of populating a modal window with HTML field..

 

by: b0lsc0ttPosted on 2009-10-19 at 13:09:00ID: 25608517

For the effect you want (a popup type "window" with the rest of the page grayed out) you can look at the sample files at http://www.ee-stuff.com/Expert/Upload/getFile.php?fid=4179 .  There are two and they were provided for the solution at http:/Q_22715336.html .

As far as the preview of the form info let me know what you need for that part, if you even need help with it.  The code to have the dynamic popup window is basic but can pretty easily be adapted.  There are other ways to do it using premade scripts or even some frameworks (like Lightbox or possible jQuery, etc).

Let me know how this helps or if you have a question.

bol

 

by: l_starter_lPosted on 2009-10-19 at 14:41:24ID: 25609300

k i think i can do the modal window.. What I need is an example of how to get data from an html form and display it in a modal window..

 

by: b0lsc0ttPosted on 2009-10-19 at 21:15:02ID: 25611025

Is the modal window another web page?  If so it would need to be able to use server script so it can read the form info and display it.  It should also make the form again (using hidden form fields) so that can be submitted to the page for processing.  Please let us know what server language you will be using to process the form and we can use the same to show the preview.  Also, if you want specific code, we need to see the form tag and fields.

bol

 

by: l_starter_lPosted on 2009-10-20 at 07:12:46ID: 25614311

Is there a way to so it client side with javascript? Can the modal window be another page I assumed it was just generated as needed?..

 

by: b0lsc0ttPosted on 2009-10-23 at 09:47:29ID: 25646167

Sorry for the delay.  It has been a busy week.

Javascript can be used, if needed, and using another page would be nice (and a way to avoid depending on Javascript).  First I need you to clarify what you mean be a modal window.  Some of the methods to make them are browser specific and there can be some big differences in the code (and it is still called a "modal window").  A key part that needs clarification is if this is really a new window (i.e. has a different url) or just an element on the page that is layered, hidden/shown, etc.

bol

 

by: l_starter_lPosted on 2009-10-23 at 10:08:14ID: 25646355

element that is on the page.. like a pop-up that shows the form preview..and when it pops up the background dims using jquery ui

 

by: b0lsc0ttPosted on 2009-10-23 at 16:31:33ID: 25649775

OK.  Then I wouldn't worry about using another page for it; there isn't really an advantage or need for that.

Please provide either a sample of the form and input, etc tags or a summary of the ones you use.  I can provide Javascript for getting the info from the form.  I would also need the id of the element if you will need help filling it with the values.

If you prefer to have it in JQuery (because you use it for all of your script) then I am not sure I can help.  I don't really use it, except in some rare cases.  I will still be glad to help but might be limited on the actual code I can provide.

Thanks though for the response and with some details from you we should be able to at least give you some code to get started.

bol

 

by: l_starter_lPosted on 2009-10-24 at 09:11:49ID: 25652807

K sample form would be

<form name="form1" action="" method="get"onSubmit="MM_openBrWindow('submission.html','','resizable=yes,width=550,height=500')">
  <p><strong>First Name:</strong>
  <input type="text" name="firstname">&nbsp;<span class="inputRequirement">*</span></p>
  <p><strong>Last Name:</strong>
  <input type="text" name="lastname">&nbsp;<span class="inputRequirement">*</span></p>
    <p><strong>Date of Birth:</strong>
  <input type="text" name="dob">&nbsp;<span class="inputRequirement">* (DD/ MM/ YYYY)</span>
  <p><strong>Email:</strong>
  <input type="text" name="email_address">&nbsp;<span class="inputRequirement">*</span>
  </p>
  <p><strong>Gender:</strong> 
  <input type="radio" name="gender" value="m"> Male <input type="radio" name="gender" value="f" > Female&nbsp;<span class="inputRequirement">*</span>
  </p>
  
  <p><strong> Select Country:</strong>
  <select name="droplist"><option value="" SELECTED></option><option value="1">USA</option><option value="2">CANADA</option><option value="3"></select>&nbsp;<span class="inputRequirement"></span>*
  </p>
  <p>
    <label> <strong>Comment/Questions</strong><br>
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
    </label>    
  </p>
 
 
	<!-- InstanceEndEditable --></div>
	<div id="greyx20goosex20site-11">
		<img src="images/grey-goose-site_11.jpg" width="342" height="1" alt="">
	</div>
 <!--Left_div-->
 
	<div id="right-place"><!-- InstanceBeginEditable name="left_tbl" -->
	
    
    <div> 
    <p><strong>Telephone Number:</strong>
      <input type="text" name="telephone">&nbsp;<span class="inputRequirement">*</span>
      </p>
    <p><strong>Street Address:</strong>
    <input type="text" name="street_address">&nbsp;<span class="inputRequirement">*</span>
    </p>
    <p><strong>Zip Code:</strong>
    <input type="text" name="postcode">&nbsp;<span class="inputRequirement">*</span></p>
    
    <p><strong>Password:</strong>
      <input type="password" name="password" maxlength="40">&nbsp;<span class="inputRequirement">*</span></p>
    <p>
      <strong>Password Confirmation:</strong>
      <input type="password" name="confirmation" maxlength="40">&nbsp;<span class="inputRequirement">*</span>
    </p>
    <p><strong>I agree to terms and conditions </strong>
  <input type="checkbox" name="agree" value="1" >*
    </p>
<h3 align="center">*-Required Fields</h3>
<p align="center">
  <label>
    Click Me !
    <br>
    <input type= "image" img src="images/submit2.png" width="60" height="60" name="submit" id="submit" value="Submit" onClick="return check_form(form1);">
    
  </label>
</h3>
    </div>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:

Select allOpen in new window

 

by: b0lsc0ttPosted on 2009-10-26 at 20:27:57ID: 25668923

Thanks for the form and input code.  I used it to make an example of the Javascript to get the info from the form.  Let me know how it works and test in various browsers.  I might need some tweaking and I didn't actually test it (but I have made the code enough it should be close).

Let me know if you have a question.

bol

var frm = document.form1;
var str = "";
var sBreak = "<br />";
str += "Name: " + frm.firstname.value + " " + frm.lastname.value + sBreak;
str += "DOB: " + frm.dob.value + sBreak;
str += "Email: " + frm.email_address.value + sBreak;
str += (frm.gender[0].checked)? "Male" + sBreak : "Female" + sBreak;
str += "County: " + frm.droplist.value + sBreak;
if (frm.comments.value != "") str += frm.comments.value + sBreak'
// repeat for other input boxes as seen above
if (frm.agree.checked) str += "They agreed." + sBreak;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:

Select allOpen in new window

 

by: l_starter_lPosted on 2009-10-26 at 21:28:59ID: 25669135

thanks b0lsc0tt: but how does this preview I don't see any code to generate a window?

 

by: b0lsc0ttPosted on 2009-10-27 at 08:59:43ID: 25673958

I thought you had that from the second expert comment.  I do have a basic example of how to do it using just html, javascript and CSS (see snippet below).  You would adapt that so the Javascript to get the form fields would fill the "formDiv" element (maybe using innerHTML).

Let me know how that helps or if you have a question.

bol

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html>
<head>
<link href="../style.css" rel="stylesheet" type="text/css" />
<title>The page</title>
<style type="text/css">
div {
	margin: 10px auto;
}
#links {
	color: red;
}
</style>
<script type="text/javascript">
function doForm() {
	document.getElementById('formDiv').style.zIndex = "100";
	document.getElementById('formDiv').style.display = "";
	document.getElementById('body').style.backgroundColor = "#303030";
	document.getElementById('button1').style.visibility = "hidden";
}
function clearForm(frm) {
	frm.title1.value = '';
	frm.protocol.options[0].selected = true;
	frm.link1.value = '';
	frm.desc1.value = '';
}
function quitForm(frm) {
	document.getElementById('formDiv').style.zIndex = "-1";
	document.getElementById('formDiv').style.display = "none";
	document.getElementById('body').style.backgroundColor = "white";
	document.getElementById('button1').style.visibility = "visible";
	clearForm(frm);
}
</script>
</head>
 
<body id="body" style="margin: 25px 115px;">
<h3>My page</h3>
<div id="content">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.</div>
<div>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.</div>
<div>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.</div>
 
<div id="links"></div>
<br /><br />
<div style="width: 25%; margin: 0 auto;">
<button id="button1" onclick="doForm();">Show Form</button>
</div>
<div id="formDiv" style="width: 60%; margin: 0 auto; padding: 10px; background-color: #ccff99; text-align: center; z-index: -1; position: absolute; top: 50px; left: 150px; border: solid 1px gray; font-weight: bold; display: none;"> <h3>AJAX Javascript Popup Form</h3>
<form name="form1" action="" method="post">
Title: <input type="text" name="title1" size="65" /><br /><br />
Protocol: 
<select name="protocol">
<option value="http://">http://</option>
<option value="https://">https://</option>
<option value="ftp://">ftp://</option>
</select>
Link: <input type="text" name="link1" size="45" /><br /><br />
Description: <input type="text" name="desc1" size="55" /><br /><br /><br />
<input type="button" name="reset" value="Quit" onclick="quitForm(this.form);" />
</form>
<br /><br />
</div>
<br /><br />
 
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:

Select allOpen in new window

 

by: l_starter_lPosted on 2009-10-30 at 14:42:40ID: 25707007

k ill try it

 

by: b0lsc0ttPosted on 2009-10-30 at 18:44:35ID: 25707979

OK.  Let me know how it works or if you have a question.

bol

 

by: l_starter_lPosted on 2009-11-02 at 08:10:10ID: 25720647

do I do it like

<script type="text/javascript">
function displayText(){
	document.getElementById('fname').innerHTML = str += "Name: " + frm.firstname.value + " " + frm.lastname.value + sBreak; 
}
 
<input type='button' onclick='displayText()' value='Show preview'/>
                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: b0lsc0ttPosted on 2009-11-02 at 09:25:20ID: 25721394

Not exactly.  I don't know that I would put the line in its own function.  The code to get the form values and show them can all be in one function.  Use the code I provided to get the values and then your line to show them would look like ...

document.getElementById('fname').innerHTML = str;

So all together it might look like the code in the snippet below.

bol

function displayText() {
  var frm = document.form1;
  var str = "";
  var sBreak = "<br />";
  str += "Name: " + frm.firstname.value + " " + frm.lastname.value + sBreak;
  str += "DOB: " + frm.dob.value + sBreak;
  str += "Email: " + frm.email_address.value + sBreak;
  str += (frm.gender[0].checked)? "Male" + sBreak : "Female" + sBreak;
  str += "County: " + frm.droplist.value + sBreak;
  if (frm.comments.value != "") str += frm.comments.value + sBreak'
  // repeat for other input boxes as seen above
  if (frm.agree.checked) str += "They agreed." + sBreak;
  // once you have all the info in "str"
  //   assumes "fname" is where you want to show the info
  document.getElementById('fname').innerHTML = str;
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: l_starter_lPosted on 2009-11-02 at 10:20:03ID: 31641770

thank you

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...